PDA

View Full Version : HOW TO REFRESH A GRID DEFINED IN A DIFFERENT JS FILE



sachin sachdeva
22 Dec 2010, 9:59 PM
HELLO
I have two panels which are having two grids that are defined in two different files.Now my requirement is, i need to refresh the second grid wen ever i perform an operation on first grid.please go through the following code

CODE FOR THE SECOND GRID
grid = new Ext.grid.GridPanel({
el : 'document-grid',
id : 'document-grid',
height : 422,
autoWidth : true,
loadMask : {
hideOnReady : false
},
viewConfig : {
forceFit : true
},
ds : dataStore,
cm : columnModel,
sm : sm,
bbar : bar,
ddGroup : 'GridDD',
enableDragDrop : true,
listeners : {
render : function() {
Ext.select(
'.x-panel-body .x-panel-body-noheader',
false).each(function(el) {
Ext.DomHelper.applyStyles(el.dom,
"height:350px");
});
}


CODE FOR THE FIRST GRID
grid = new Ext.grid.GridPanel({
el : 'document-grid',
id : 'document-grid',
height : 422,
loadMask : {
hideOnReady : false
},
autoWidth : true,
viewConfig : {
forceFit : true
},
ds : dataStore,
cm : columnModel,
sm : sm,
bbar : bar,
deferredRender : true,
ddGroup : 'GridDD',

enableDragDrop : true,
listeners : {
render : function() {
Ext.select(
'.x-panel-body .x-panel-body-noheader',
false).each(function(el) {
Ext.DomHelper.applyStyles(el.dom,
"height:370px");
});
}
}
});
grid.render();
buttons : [{ //NEED TO REFRESH THE GRID OF FILE 2 IN THIS BUTTON CLICK
text : 'Reject',
formBind : true,
handler : function() {
var reasonreject = Ext.getCmp("reasonreject").getValue();


please help me .....

Jaitsu
23 Dec 2010, 12:54 AM
Post your code in the proper tags, I took the liberty of doing so...



grid = new Ext.grid.GridPanel({
el: 'document-grid',
id: 'document-grid',
height: 422,
autoWidth: true,
loadMask: {
hideOnReady: false
},
viewConfig: {
forceFit: true
},
ds: dataStore,
cm: columnModel,
sm: sm,
bbar: bar,
ddGroup: 'GridDD',
enableDragDrop: true,
listeners: {
render: function () {
Ext.select('.x-panel-body .x-panel-body-noheader', false).each(function (el) {
Ext.DomHelper.applyStyles(el.dom, "height:350px");
});
}




grid = new Ext.grid.GridPanel({
el: 'document-grid',
id: 'document-grid',
height: 422,
loadMask: {
hideOnReady: false
},
autoWidth: true,
viewConfig: {
forceFit: true
},
ds: dataStore,
cm: columnModel,
sm: sm,
bbar: bar,
deferredRender: true,
ddGroup: 'GridDD',

enableDragDrop: true,
listeners: {
render: function () {
Ext.select('.x-panel-body .x-panel-body-noheader', false).each(function (el) {
Ext.DomHelper.applyStyles(el.dom, "height:370px");
});
}
}
});
grid.render();
buttons: [{ //NEED TO REFRESH THE GRID OF FILE 2 IN THIS BUTTON CLICK
text: 'Reject',
formBind: true,
handler: function () {
var reasonreject = Ext.getCmp("reasonreject").getValue();


There is so much wrong with this code, have you actually tried to run this in your browser? It should be throwing an error

sachin sachdeva
23 Dec 2010, 2:15 AM
Mate i have posted only a part of my code how would it run ..........i just want to know that if have defined a grid in file say A.js and i want to refresh that grid from a file name B.js how wolud u do it .........

tokkaido
23 Dec 2010, 6:13 AM
if you define a storeId for the store asociated to your grid yo can do this:

Ext.StoreMgr.lookup('storeId_of_my_store').reload();

even you can send params in it

Ext.StoreMgr.lookup('storeId_of_my_store').reload({
params: {
my_param1: my_value1,
my_param2: my_value2
}
});

fmo555
23 Dec 2010, 6:31 AM
Ext.getCmp('document_grid').getStore().load();

dkarso
23 Dec 2010, 7:25 AM
And to make the answers more complete: having 2 separate js files is not an issue if they are both loaded in the same html/php/etc page. Just make sure the objects have variables or id's you can reference in other parts of the script. It get's loaded in the memory anyway.