EditorGridPanel表格應用

var personStore = new Ext.data.JsonStore({
            method : "POST",
            fields : ["列名1","列名2"]        //與Grid列一致,至少列名稱一致
        });
        
        var confirm = new Ext.grid.EditorGridPanel({
            store:personStore,
            columns:[
                {id:"列名1",header:"",dataIndex:"列名1",width :100,align:'left',resizable:true,sortable:true },
                {id:"列名1",header:"",dataIndex:"列名2",width :100,align:'left',resizable:true,sortable:true,editor:new Ext.form.TextField({})},//可編輯
            ],
            layout:'fit',
            listeners: {
                afteredit: function(val) {
                    val.record.set("列名1", val.record.get("列名2"));//修改數據,列1數據同步列2數據
                 }
            },
        });數組

        var win = new Ext.Window({
            layout:'fit',
            title:'',
            width:1020,
            height:600,
            closeAction:'hide',
            items:[confirm],//在彈窗中嵌套表格;
            modal:true,
            listeners : {
                 'hide':function(){
                     store.reload();
                 },
                    'show':function(){
                 }
             },
            buttons:[
                {
                    text:'確認',
                    handler:function(){
                        var store=confirm.getStore() //獲取grid中的store對象
                        var s=store.getModifiedRecords()//返回的是全部被修改的行 即Ext.data.Record的對象數組

                        for(var i = 0, r; r = s[i]; i++){
                            var 字段名= r.get('列名');
                        }
                    }
                },{
                    text:'取消',
                    handler:function(){
                        win.hide();
                    }
                }]
        });ide

相關文章
相關標籤/搜索