extjs如何重置我修改后的商店....(我的pruneMOdifiedRecords无法正常工作,..)

时间:2011-03-04 03:58:54

标签: extjs

这里是我的js文件:

var fm = Ext.form;
var grid = new Ext.grid.EditorGridPanel({
    height: Ext.get("content").getHeight(),
    width: Ext.get("content").getWidth(),
    store: store,
    pruneModifiedRecords : true,
    clicksToEdit : 1,
    columns:[
        {header: "Kd.Rayon",        dataIndex: 'KD_RAYON',  width:60,   sortable: false},//
        {header: "Kd.Sek",          dataIndex: 'KD_SEK',    width:60,   sortable: false},//
        {header: "Paralel",         dataIndex: 'PARALEL',   width:50,   sortable: false, editor: new fm.TextField({allowBlank: false})},
        {header: "Absen",           dataIndex: 'ABSEN',     width:50,   sortable: false, editor: new fm.TextField({allowBlank: false})},
    .......
    ],

    stripeRows: true,
    loadMask : {
        msg : 'Loading data...'
    },
    //autoExpandColumn: 'ALAMAT',
    title: 'Siswa', 

    sm: new Ext.grid.RowSelectionModel({singleSelect: true}),
    tbar: [{
        id : 'btnSave',
        iconCls : 'disk',
        tooltip : 'Simpan perubahan data',
        disabled: true,
        text : 'Simpan',
        handler: function(){
            var  records = grid.store.getModifiedRecords();
            if (records.length<=0)
                Ext.Msg.alert("Data","Tidak ada perubahan");
            else{
                var data = [];
                for (i=0; i<records.length; i++){
                    data.push(records[i].data);
                }
                data = Ext.encode(data); 
                Ext.getBody().mask();
                Ext.Ajax.request({ 
                  //url: 'test.php',
                  url: 'php/crud.php',
                  params: {
                    data: data,
                    ACT : "U",
                    FORM: "SISWA",
                    KD_PROP:Pendas.kd_prop,
                    KD_RAYON:Pendas.kd_sek.substring(2,4),
                    KD_SEK:Pendas.kd_sek.substring(4,7)
                  },
                  success: function(res,obj){
                    var json = res.responseText;
                    var o = eval("("+json+")");
                    Ext.Msg.alert("Data",o.info);
                    store.reload();
                    Ext.getBody().unmask();
                  }
               });
            }
        }
    }]
});

这里的情况,.... 首先,我编辑第一行,..
我保存它,它返回true,返回的地方让我们说“Upadate success”,...
但是,当我点击按钮保存两次,...
它重新发送modifiedRecords ...

我做错了吗?,... 如何重置我的“修改记录”

1 个答案:

答案 0 :(得分:0)

pruneModifiedRecords设置了EditorGridPanel,但它必须位于Store上。

http://dev.sencha.com/deploy/dev/docs/source/Store.html#cfg-Ext.data.Store-pruneModifiedRecords