ylove 2009-06-29 17:26
浏览 284
已采纳

Extjs的ItemSelector中的toStore重新加载的问题

在使用ItemSelector的时候,根据传入的参数重新加载toStore,但是加载后的toStore数据不刷新还是第一次加载的数据。具体代码如下:
[code="java"]
{
id : 'assignResource',
text : '分配资源',
icon : 'images/drop-yes.gif',
cls : 'x-btn-text-icon',
handler : function() {

        var sm = grid.getSelectionModel();
        var sel = sm.getSelected();

        if (sm.hasSelection()) {

            getResourcesToStoreJsonUrl = getResourcesToStoreJsonUrl
                    + "&resourceList=" + sel.data.id;
            alert(getResourcesToStoreJsonUrl);

            var resourceResultsStore = new Ext.data.Store({
                        url : getResourcesJsonUrl,
                        reader : new Ext.data.JsonReader({
                                    root : 'rows', // 返回结果集
                                    pruneModifiedRecords : true,
                                    totalProperty : 'results', // 返回总条数
                                    id : 'returnValue' // 主键
                                }, [{
                                            name : 'returnValue'
                                        }, {
                                            name : 'displayText'
                                        }])
                    });

            var resourcesToStore = new Ext.data.Store({
                        url : getResourcesToStoreJsonUrl,
                        reader : new Ext.data.JsonReader({
                                    root : 'rows', // 返回结果集
                                    pruneModifiedRecords : true,
                                    totalProperty : 'results', // 返回总条数
                                    id : 'returnValue' // 主键
                                }, [{
                                            name : 'returnValue'
                                        }, {
                                            name : 'displayText'
                                        }])
                    });

            // 分配资源form
            var itemSelect = new Ext.ux.ItemSelector( {                 
                name : "resourcesList",
                fieldLabel : "资源组分配",
                dataFields : ["returnValue", "displayText"],
                fromStore : resourceResultsStore,
                toStore : resourcesToStore,
                msWidth : 250,
                msHeight : 200,

                valueField : "returnValue",
                displayField : "displayText",
                imagePath : "images/",
                toLegend : "已分配资源",
                fromLegend : "现有资源",

                toTBar : [{
                    text : "清除",
                    handler : function() {
                        var i = assingResourceForm.getForm()
                                .findField("itemselector");
                        i.reset.call(i);
                    }

                }]

            });



            resourcesToStore.reload();
            resourceResultsStore.reload();              var assingResourceForm = new Ext.form.FormPanel({
                        url : postUrl,
                        xtype : 'fieldset',
                        autoHeight : true,
                        layout : 'form',
                        items : [itemSelect]
                    });



                 var assignRWindow = new Ext.Window({
                            layout : 'fit',
                            title : '<div style="text-align:center">分配资源</div>',
                            width : 800,
                            height : 520,
                            closeAction : 'hide',
                            plain : true,
                            maximizable : true,
                            items : new Ext.TabPanel({
                                        region : 'center',
                                        border : false,
                                        activeTab : 0,
                                        items : [{
                                                    title : "资源分配登记",
                                                    autoScroll : true,
                                                    items : [assingResourceForm]
                                                }]
                                    }),
                            buttons : [{
                                text : '保存',
                                handler : function() {
                                    // 保存修改信息

                                    if (assingResourceForm.getForm()
                                            .isValid()) {

                                        Ext.Msg
                                                .alert(
                                                        '数据提交',
                                                        '新分配的资源ID为以下: <br />'
                                                                + (assingResourceForm
                                                                        .getForm()
                                                                        .getValues(true)));
                                        var conn = Ext.lib.Ajax
                                                .getConnectionObject().conn;
                                        conn
                                                .open(
                                                        "post",
                                                        assignResourcesUrl
                                                                + "&"
                                                                + assingResourceForm
                                                                        .getForm()
                                                                        .getValues(true),
                                                        false);
                                        conn.send(null);
                                        /*
                                         * if
                                         * ((conn.responseText).indexOf('correct') ==
                                         * -1) { Ext.MessageBox.alert('提示',
                                         * '输入的验证码不正确,请重新输入!');
                                         * authImg.focus(); return false; }
                                         */

                                    } else {
                                        Ext.MessageBox.alert('错误',
                                                '请修正页面提示的错误后提交。');
                                    }

                                }
                            }, {
                                text : '关闭',
                                handler : function() {
                                    assignRWindow.hide();
                                }
                            }],

                            listeners : { // 保证最大化后窗口中的滚动条不出问题
                                close : function(w) {
                                    w.restore();
                                },
                                maximize : function(w) {
                                    w.setPosition(document.body.scrollLeft,
                                            document.body.scrollTop);
                                }
                            }
                        });


            assignRWindow.setPosition(0, 3);
            assignRWindow.show();

        } else {
            Ext.MessageBox.alert('提示', '请选择要为其分配资料的组!').getDialog('提示')
                    .setPosition(300, 150);
        }

    }
}

[/code]

有遇到过这个问题的朋友还请指点一下。
感谢!

  • 写回答

2条回答 默认 最新

查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?