如何在 GRID 面板中获取记录字段的值?我有下一个代码:
var gridTablaConsulta = Ext.create('Ext.grid.GridPanel', {
title:'Consulta Tabla lotes',
store: storeTabla,
columns: [
Ext.create('Ext.grid.RowNumberer'),
{text: "NRBE", width: 60, sortable: true, dataIndex: 'NRBE'},
{text: "APLIC", width: 60, sortable: true, dataIndex: 'APLIC'},
{text: "FORM", width: 60, sortable: true, dataIndex: 'FORM'},
{text: "VERFOR", width: 60, sortable: true, dataIndex: 'VERFOR'},
{text: "FECLOT", width: 60, sortable: true, dataIndex: 'FECLOT'},
{text: "HORLOT", width: 60, sortable: true, dataIndex: 'HORLOT'},
{text: "TIPPAPLO", width: 60, sortable: true, dataIndex: 'TIPPAPLO'},
{text: "TAMPAP", width: 60, sortable: true, dataIndex: 'TAMPAP'},
{text: "FECINIIM", width: 60, sortable: true, dataIndex: 'FECINIIM'},
{text: "FECINIOB", width: 60, sortable: true, dataIndex: 'FECINIOB',editor:{xtype:'textfield', allowBlank:true}},
{text: "ESTLOT", width: 60, sortable: true, dataIndex:'ESTLOT',editor:{xtype:'textfield', allowBlank:true}},
{text: "TOTPAGGE", width: 60, sortable: true, dataIndex: 'TOTPAGGE'},
{text: "TOTPAGIM", width: 60, sortable: true, dataIndex: 'TOTPAGIM'},
{text: "DESLOT", width: 60, sortable: true, dataIndex: 'DESLOT'},
{text: "TIPDIF", width: 60, sortable: true, dataIndex: 'TIPDIF'},
{text: "DIADIF", width: 60, sortable: true, dataIndex: 'DIADIF'},
{text: "FECALT", width: 60, sortable: true, dataIndex: 'FECALT'},
{text: "FECMOD", width: 60, sortable: true, dataIndex: 'FECMOD'},
{text: "TERMOD", width: 60, sortable: true, dataIndex: 'TERMOD'},
{text: "HORMOD", width: 60, sortable: true, dataIndex: 'HORMOD'}
],
selType: 'rowmodel',
plugins: [
Ext.create('Ext.grid.plugin.RowEditing', {
clicksToEdit: 2
})
],
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
});
}
}
});
我希望当我显示网格并在寄存器中脉冲时,我可以评估字段“ESTLOT”的值,然后我将根据先前的值更改该值。
我的问题是我只知道谁来获取属于该寄存器的所有字段,但我只想要 ESTLOT 值,将此值传递给我将评估该值的编辑函数。
谢谢大家,我需要很多帮助。
编辑2:
listeners: {
beforeedit: function(editor, e, eOpts) {
var grid = Ext.getCmp('gridTabla'); // or e.grid
var hoy = new Date();
dia = hoy.getDate();
if(dia<10)
{
dia=String("0"+dia);
}
mes = hoy.getMonth();
if(mes<10)
{
mes=String("0"+mes);
}
anio= hoy.getFullYear();
fecha_actual = String(anio+""+mes+""+dia);
//alert(fecha_actual);
var mola = e.record.data.ESTLOT;
alert(mola);
if (e.record.data.ESTLOT === '02') {
if (e.record.data.FECMOD === fecha_actual)
{
e.cancel = false; //permite
}
else{
e.cancel = true;
}
} else
{
e.cancel = false; //permite
}
},
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
});
}
}
});
现在我想将 beforeedit 中的 var = "mola" 包含在编辑中以进行最后一次验证
编辑 3 新代码和失败
listeners: {
beforeedit:
function preditar(editor, e, eOpts, mola) {
var grid = Ext.getCmp('gridTabla'); // or e.grid
var hoy = new Date();
dia = hoy.getDate();
if(dia<10)
{
dia=String("0"+dia);
}
mes = hoy.getMonth();
if(mes<10)
{
mes=String("0"+mes);
}
anio= hoy.getFullYear();
fecha_actual = String(anio+""+mes+""+dia);
//alert(fecha_actual);
var mola = e.record.data.ESTLOT;
//alert(mola);
editar(mola);
if (e.record.data.ESTLOT === '02') {
if (e.record.data.FECMOD === fecha_actual)
{
e.cancel = false; //permite
}
else{
e.cancel = true; //mo permite
}
} else
{
e.cancel = false; //permite
}
},
edit:
function editar(e, context, mola){
var record = context.record;
var recordData = record.getData();
var mola2= mola;
alert(mola2);
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
});
}
}
});
它说我“记录是空的,它不是一个对象”并在这里出现: var record = context.record;
再次感谢。