PDA

View Full Version : Buffered Scrolling and RowEditingPlugin and updating a single record



anshumanmehta
29 May 2012, 1:11 PM
I have been using extjs4.x with a spring-data and a restful back-end and have got significant success. I managed to make the buffered scrolling and remote filtering work but have been stuck for somewhile on how to manage the updating of a single record from my backend (where a single column is used to compute other column's values). In essence i have a mssql backend with computed columns.
With autoload:true and autosync:true and no buffered scrolling everything works fine.
But as soon as i move to bufferedscrollin g(autoLoad:true is not option because of ie8 and other environment specific issues) i cannot retrieve the new values in the updated grid.

35728
I am using the MVC layout as suggested by sencha, and the non-editable columns in the first image above are calculated columns. ie. they are calculated on the basis of the input value. So the input value is updated at he backend and the server side controller sends back the appropriate json response with the record (and all updated columns which are updated) but the grid is not updated as can be seen in the second image.
If i refresh the grid the data is correct , as in the third image .

How can i force the update /load of an entire record ?



Ext.define('App.store.SomeStore', {
extend: 'Ext.data.Store',
model: 'App.model.SomeModel',
autoSync: true,
remoteFilter:true,
buffered : true,
leadingBufferedZone:200,
purgePageCount:0,
pageSize:50,
proxy: {
type: 'ajax',
api :
{
read : 'some/fetch', // have pagination implemented at the server end
update:'some/update', // returns the entire record which is updated
create :'some/create',
destroy : 'some/delete'
},
reader :
{
type : 'json',
root : 'some.content', //for pagination
successProperty : 'success',
idProperty : 'id',
totalProperty: 'some.totalElements' //for pagination
},
writer :
{
type : 'json',
allowSingle : true
}
}
,
listeners :
{
update : function(record,operation, eOpts)
{
if(eOpts == "commit") // trying to get the explicit record which is updated
{
var someModel = this.getProxy().getModel();
//[Exception: TypeError: Cannot call method 'load' of undefined]
someModel.load(operation.data.id,
{
scope: this,
failure: function(record, operation) {.. },
success: function(record, operation) { ..}
});


}
}
}
});


Do i need to change the read url for the proxy ? Shud not the entire record be updated when the selmodel for the grid is 'rowmodel' ? Is some modification required for the reader since originally i return a list of records within a page object but in an update only a single record ? I am not sure about this because i implemented another grid with exactly the same logic but without calculated columns (non-editable columns in the grid) and it works fine.
How can i refresh the entire record ?

anshumanmehta
29 May 2012, 1:29 PM
yes, it works with changing the implementation from the server side to reflect the actual data as returned during pagination.