PDA

View Full Version : Grid : How to use the reconfigure method to set up new tbar handler !



naspar
24 May 2010, 1:28 AM
hello Guys,
i have a question for you .. is it possible to use the "reconfigure" grid method to "refresh" the tbar handler ?
I have instanced a grid control with its tbar and three button . Each button has its handler (new,delete,modify) because i would like to open a new form based on the data that are in the grid (classic CRUD application). The problem happen when the grid is already rendered and i try to use the reconfigure method wich does not refresh the grid. As you can see in my code below, the NEW button works proper only when i click on it the first time . .it takes the right table and open its associated form. Once the grid been has been created ans using the method reconfigure to change the table, if i try to click on the NEW button, a previous table is recorded (in the variable "table") and the wrong form is opened. Is there any manner to reconfigure the tbar object after having called the reconfigure method ?



var mainGrid = new Ext.grid.GridPanel({
title: title,
store: store,
iconCls: 'silk-grid',
layout: 'fit',
id: 'mainGrid',
cm: cm,
autoWidth: true,
loadMask: true,
clicksToEdit: 1,
viewConfig: {
onDataChange: function(){
this.cm.setConfig(store.reader.jsonData.columns);
this.syncFocusEl(0);
}
},
tbar: {
items: [{
text: 'New',
iconCls: 'silk-add',
handler: function(){

switch (table) {
case 'table_1':
var form = new frmTable1('INSERT');
break;
default:
alert('The form has not been configured yet !');
}

win = new Ext.Window({
layout: 'form',
autoHeight: true,
width: 400,
closeAction: 'hide',
items: [form]
});
win.show();
}
}, '-', {
text: 'Delete',
iconCls: 'silk-delete',
handler: function(){
}
}]
},
bbar: new Ext.PagingToolbar({
pageSize: 35,
id: 'pagingBar',
store: store,
displayInfo: true,
displayMsg: 'Records : {0} - {1} di {2}',
emptyMsg: "No rows available."
})
});

store.load()






grid.setTitle(title);

grid.reconfigure(newStore, newCm);
Ext.getCmp('pagingBar').bind(newStore);
newStore.load({
params: {
start: 0,
limit: 35
}
});



thank you !!