PDA

View Full Version : Ext.Grid - how to reload it after only defined column is changed?



softm
25 Jan 2011, 2:11 PM
I have grid which is loaded wtih this:

var proxy = new Ext.data.HttpProxy({
url: 'answer.php?act=load-grid-profiles',
method: 'post',

api: {

read : {url: 'answer.php?act=loadnews&' , method: 'post'},
create : {url: 'answer.php?act=newnews&id=' , method: 'post'},
update : {url: answer.php?act=editnews&id=' , method: 'post'},
destroy : {url: 'answer.php?act=delnews&id=' , method: 'post'}
}


});

All works good. But i have one column (with chackboxes), on which changed i want - full grid be reloaded. Cause when it changes, other records also are affected (only one record can have checked checkbox).

I try return an variable in json (reload = true) , when

update : {url: answer.php?act=editnews&id=' , method: 'post'},

is executed. But dont understood where to analise it is returned.

Also i try insert in event store.on - update

store.on({
'update':{
fn: function(store, records, options){
update_manage();

if ( options == "commit" ) store.reload();
},
scope:this
});

It reloads, but alter anyone column is updated.

Pls help me - make it reload grid, after my column named "display" is changed.


,Tnx.

softm
25 Jan 2011, 2:28 PM
Also i try thisway:



// create the editor grid
var grid = new Ext.grid.EditorGridPanel({
store: store,
cm: cm,
renderTo: '{/literal}{$gridname}{literal}',
width: 898,
height: 520,
frame: true,
loadMask: true,
clicksToEdit: 1,
plugins: [displayColumn],
listeners:
{

'cellclick':{
fn: function(grid, rowIndex, columnIndex, e) {
// Get the Record for the row
var record = grid.getStore().getAt(rowIndex);
// Get field name for the column
var fieldName = grid.getColumnModel().getDataIndex(columnIndex);
var data = record.get(fieldName);

console.info(fieldName, "[cellclick]");

}
},



But cause this cell is from plugin (displayColumn) the event cellclick is not raised on click on this column. All others - yes, it shows that event was, this one - no ...

... Arsen

ryanyoungsma
25 Jan 2011, 5:18 PM
Are you using a custom plugin for the checkcolumn? did you register an event in this plugin to listen too? Would need to see your column model and plugin code.

softm
25 Jan 2011, 5:55 PM
yes, am using plugin, but i take it from extjs faq (or example)
Cause it difficult to make this event parser, i
find out other way - to solve this problem:


// add listener for event
proxy.on('write', function( DataProxy, action, data, response, rs, options ) {
// console.info( response, "[proxy-on-write]" );
if ( response.message == "~~~reloading" )
store.reload();

});
And this ~~~reloading returns php, which analyses, that only "checkbox" column is updated.



if ( isset($p_data_display) )
$arr_json[ "message" ] = "~~~reloading";
...

echo json_encode( $arr_json );
exit;


Am updating only 1 column a time.

PS. Not elegant enought ... i know.