在Ext.grid.Panel单元格中解析脏标志 [英] Resolving Dirty Flag in Ext.grid.Panel cell

查看:99
本文介绍了在Ext.grid.Panel单元格中解析脏标志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个Ext JS网格中,我正在编辑单个单元格。在其中一列中,我有一个保存按钮,它将触发保存事件。如何在编辑的单元格中删除脏标志(在下图中的红色框中)?我不知道如何使用代理执行创建,更新和销毁选项,因为文档有一个很好的例子,所以我打算为这些步骤做一个AJAX请求,直到我可以采取实际的Sencha培训。但是,如果我直接使用存储区和代理服务器来处理脏标志,我宁愿以正确的方式进行操作。





JavaScript代码

 },{
header:'Save',
xtype:'actioncolumn',
align:'center',
width:50,
sortable:false,
items:[ {
图标:'./Scripts/extjs/examples/shared/icons/fam/add.gif',
工具提示:'Save Row',
处理程序:function(grid,rowIndex, colIndex){
store.sync();
alert('saving');
}
}]
},{
header:'Delete',
xtype:'actioncolumn',
align:'center',
width:50,
sortable:false,
items:[{
icon:'./Scripts/extjs/examples/shared/icons/fam/delete.gif',
tooltip:'Delete Task',
处理程序:function(grid,rowIndex,colIndex){
store.removeAt(rowIndex);
store.sync();
提醒('删除');

}]
}


解决方案 div>

网格反映了底层商店的状态,它是基于您的数据模型的记录集合。所以作为一个快捷方式,你可以这样做:

  //保存处理程序
处理程序:函数(网格,rowIndex,colIndex){
store.sync(); //现在不起作用

store.getAt(rowIndex).commit(); //提交更改,清除脏标志

alert('Record should be clear');
}


In an Ext JS grid, I'm editing individual cells. In one of the columns I have a Save button which fires the Save event. How can I remove the dirty flag (in red box in my image below) in the edited cell? I don't know how to perform the create, update and destroy options with the proxy because the documentation have a good example, so I'm planning on doing an AJAX request for these steps until I can take actual Sencha training. However, if the dirty flag resolves itself if I work the store and proxy directly, I'd prefer to do it the right way.

JavaScript Code:

            }, {
                header: 'Save',
                xtype: 'actioncolumn',
                align: 'center',
                width: 50,
                sortable: false,
                items: [{
                    icon: './Scripts/extjs/examples/shared/icons/fam/add.gif',
                    tooltip: 'Save Row',
                    handler: function (grid, rowIndex, colIndex) {
                        store.sync();                            
                        alert('saving');
                    }
                }]
            }, {
                header: 'Delete',
                xtype: 'actioncolumn',
                align: 'center',
                width: 50,
                sortable: false,
                items: [{
                    icon: './Scripts/extjs/examples/shared/icons/fam/delete.gif',
                    tooltip: 'Delete Task',
                    handler: function (grid, rowIndex, colIndex) {
                        store.removeAt(rowIndex);
                        store.sync();
                        alert('deleting');
                    }
                }]
            }

解决方案

A Grid reflects the state of underlying Store, which is a collection of records based on your data Model. So as a shortcut before you have your Ajax proxy figured out, you can do this:

// Save handler
handler: function(grid, rowIndex, colIndex) {
    store.sync(); // Doesn't work now

    store.getAt(rowIndex).commit(); // Commit changes, clearing dirty flag

    alert('Record should now be clear');
}

这篇关于在Ext.grid.Panel单元格中解析脏标志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆