PDA

View Full Version : Grid panel - Sync functionality



gollamudi
20 Jan 2012, 7:32 AM
Hi,

I am working on EXT JS 4 - MVC architecture.

I have a Grid Panel whose store is as follows




Ext.require([
'Ext.data.*'
]);


Ext.define('TradeAdjustment.store.TradeAdjustmentGrid',{


extend:'Ext.data.Store',
autoLoad: true,
requires:'TradeAdjustment.model.TradeAdjustmentGridModel',
model:'TradeAdjustment.model.TradeAdjustmentGridModel',
pageSize: 50,
storeId: 'tradeAdjustmentGridID',
proxy: {
type:'ajax',
url: '/AdminTool/AdminToolServlet/TRADE_ADJUSTMENT?dispatchAction=list',
extraParams: {act:'load'},
reader: {
type : 'json',
root : 'tradeadjustmentgrid',
totalProperty: 'total'
},
writer: {
type: 'json',
writeAllFields : true, //just send changed fields
allowSingle :false //always wrap in an array
// nameProperty: 'mapping'
},
exception: function (proxy, response, operation) {
var json = Ext.decode(response.responseText);
console.log('STORE PROXY EXCEPTION');
if (json) {

} else {

}

}
},
listeners : {
//exception: function(proxy, res) {
exception: function (proxy, res, operation) {
var json = Ext.decode(res.responseText);
console.log(proxy);
//console.log(type);
var responseObj = Ext.JSON.decode(res.responseText);
var success = responseObj.success;


if(success == true)
{
console.log('SUCCESS');
}
else
{
console.log('FAILURE');
}
}
}
});


And my response after the GRID is sync is like this


{"success":"false","total":1,"tradeadjustmentgrid":[{"adjustmentTradeIndicator":"No","adjustmentType":"6","description":"Description0.5914142383874671","gainLossIndicator":"Yes","inputPrice":"Yes","requiresNotification":"No","tradeShareIndicator":"Yes"}]}

The result can either be success: true - when all the records have successfully validated on client side
or success:false - when error records are sent from server side.

Can you please help me configure this requirement.

Thanks
Ravi

mitchellsimoens
20 Jan 2012, 8:54 AM
So what functionality do you currently have?

gollamudi
21 Jan 2012, 8:00 AM
I have written exception listener on my store as well as proxy, but neither of them is getting called on the response.

Can you gimme an example where my Modified records from store when sync'ed and sent to server for DB operations.

Some of the records are saved successfully and some fail server side validation.

I want to mark successfully saved records as background GREEN

And server-side validation failed records as background RED