PDA

View Full Version : Ext.grid.plugin.RowEditing sql consult



deckard27
10 Jun 2013, 10:20 PM
Hi all, in first time i am a new user in this marvelous framework, i have a problem because i dont know how to do a consult when i change some rows in my grid, i dont have problem to do the changes in the grid, but when i push the botton of save, i dont know how to pass that changes to my servlet where i procces the consult, my code is the next.



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
})
],

tbar: [
{
text: 'Guardar modificaciones',
handler: function ()
{
storeTabla.getUpdatedRecords();
modificarRegistro();
}
}
]


});

var modificarRegistro = function(){
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(response){

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

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


Thanks for all.

friend
11 Jun 2013, 5:20 AM
The proxy of your grid's store can be configured to send updates to the servers. Read the Application Architecture (http://docs.sencha.com/extjs/4.2.1/#!/guide/application_architecture) guide, and in particular see section Saving to the Server.

deckard27
11 Jun 2013, 6:04 AM
My problem is that i use a servlet, and i tried to do an update in sql.... i dont know how to use grid if i want all the camps of the row where i have had a change, thats my problem. Probably the doc is not enough to solve my problem, for that i have posted here my problem, because really i need some help to solve this problem, i have a web apliccation but in others displays i dont have problem because i do all with textfield, the problem is here that i need to do with grid.... and i dont want to change all the system, only find a system wehere a pase to the variable f.e. (DPNrbe) the value that hi has in the grid, and in the case of the two that can be chaneged passed the new value of the camp. I need pass all the values because then i do a sql update, and in sometimes two enter of the bbdd are similar escepto one camp.

friend
11 Jun 2013, 9:04 AM
If your heart is set on manually updating modified records from the store:



var records = yourStore.getModifiedRecords();


You could then walk the array and do whatever you like. After doing your updates, call yourStore.commitChanges(), where this will flush the modified records cache.

deckard27
11 Jun 2013, 9:16 AM
Can you pasted an example please? i am a newbie in EXTjs and i think that i need some help. on the other hand i need too the records not changed, i need all records to do the sql update.