EXT js编辑行

时间:2013-06-11 06:57:54

标签: extjs

我有一点问题,在这段时间我决定在每次使用Ext.grid.plugin.RowEditing更新一行时在sql中进行咨询,我将代码的一部分粘贴到我遇到问题的地方。 / p>

   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'},
        {text: "ESTLOT", width: 60, sortable: true, dataIndex: 'ESTLOT'},
        {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', editor: {xtype:'textfield', allowBlank:false}},
        {text: "DIADIF", width: 60, sortable: true, dataIndex: 'DIADIF', editor: {xtype:'textfield', allowBlank:false} },
        {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: {
        edit: function(e){
            Ext.Ajax.request({
                url: 'http://localhost:8080/MyMaver/ServletTablaLotes',
                method: 'POST',

                params: {
                    Funcionalidad: 'Modificar',
                    DPNrbe: Ext.getCmp('DPNrbe').getValue(),
                    DPAplic: Ext.getCmp('DPAplic').getValue(),
                    DPForm:Ext.getCmp('DPForm').getValue(), 
                    DPVersFor: Ext.getCmp('DPVerFor').getValue(),
                    DPFecLot: Ext.getCmp('DPFecLot').getValue(),
                    DPHorLot: Ext.getCmp('DPHorLot').getValue(),
                    DPTippApl: Ext.getCmp('DPTippApl').getValue(),
                    DPTamPap: Ext.getCmp('DPTamPap').getValue(),
                    DPFecinIm: Ext.getCmp('DPFecinIm').getValue(),
                    DPFeciNio: Ext.getCmp('DPFeciNio').getValue(),
                    DPEstLot: Ext.getCmp('DPEstLot').getValue(),
                    DPTotPagge: Ext.getCmp('DPTotPagge').getValue(),
                    DPTotPagim: Ext.getCmp('DPTotPagim').getValue(),
                    DPDesLot: Ext.getCmp('DPDesLot').getValue(),
                    DPTipDif: Ext.getCmp('DPTipDif').getValue(),
                    DPDiaDif: Ext.getCmp('DPDiaDif').getValue(),
                    Entorno:  Ext.getCmp('Entorno').getValue()
                 },
                success: function(){

                      var text = response.responseText;
                        // process server response here
                      respuestaModificacion(text);

                    },
                    failure:  function (){
                    alert("Desde failure");
                    },
                    exception: function (){
                   alert("Desde exception");
                 }
            });
        }
    }


});

我有一个问题,我必须保存我在更新时在rox中所做的更改。我认为这个DPNrbe:Ext.getCmp('DPNrbe')。getValue(),是不正确的,但我必须在这里做正确的sql咨询。

我需要保存行的所有值,即使是不更改阵营,因为我必须在sql中进行下一次咨询(带有更改值的更新)。

再次感谢所有人。

1 个答案:

答案 0 :(得分:0)

实际上,您的每个列都没有编辑器字段,因此您无法以这种方式访问​​单元格值。但是,您在edit事件的文档中看到它将context参数传递给侦听器,您可以在其中访问正在编辑的存储记录。

例如:

        edit: function(e, context){

            // see edit event doc
            var record = context.record;

            // get the row's data (will be updated from the last edit)
            var recordData = record.getData();

            console.log(recordData); // see what's in there

            // add custom param
            recordData.Functionalidad = 'Modificar';

            Ext.Ajax.request({
                url: 'http://localhost:8080/MyMaver/ServletTablaLotes',
                method: 'POST',

                // merge row data with other params
                params: recordData,

                // callbacks code omitted
                success: function() { /* ... */ },
                failure:  function() { /* ... */ },
                exception: function () { /* ... */ }
            });
        }

另外,只是一个建议,也许您应该考虑在请求中使用jsonData而不是params,因为JSON可能会在服务器端为您节省一些烦人的字符串强制转换。