我试图在可编辑网格中将记录从 EXT js 中的 a 传递beforeedit到 a edit,因为我需要根据该字段的先前值进行验证。例如,我有行(电话号码),当我尝试编辑该字段时,只有电话以 6 开头时我才能执行此操作,但如果电话以 9 开头我只能将其更改为另一个以 9 开头的电话。
我在代码中使用 next ,但我不知道如何将编辑之前的值传递给编辑函数。这是我的代码:
listeners: {
beforeedit: {
scope: this,
fn: function(e, context2){
var record2= context2.record;
var recordData2=record2.getData();
alert(JSON.stringify(recordData2));
}
},
edit: function(e, context){
var record = context.record;
var recordData = record.getData();
recordData.Funcionalidad = 'Modificar';
alert(JSON.stringify(recordData));
Ext.Ajax.request({
url: 'http://localhost:8080/MyMaver/ServletTablaLotes',
method: 'POST',
// merge row data with other params
params: recordData
});
}
}
Run Code Online (Sandbox Code Playgroud)
如何将先前的值引用到 edit:function ?
小智 5
尝试这个:
beforeedit: function(editor, e, eOpts) {
var grid = Ext.getCmp('gridId'); // or e.grid
if (e.record.data.phoneNumber === 'your condition') {
//you code ..
e.cancel = false; //may edit the record
} else {
e.cancel = true; //not allowed to edit
}
},
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5835 次 |
| 最近记录: |