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条)

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料