PDA

View Full Version : How to populate an Ext.Grid declared in a js file to another js file



dev_java
21 Jun 2010, 3:49 AM
Hi All,

I am facing a problem in extending Ext.Grid component.

I have two js files sample1.js and main.js
I want to populate the Grid declared in sample1.js file to the Ext.Window in main.js file.

I want to break down the components in separate js files and then integrate in main.js file
Can any one help me on this.

Code for sample1.js file


MyGrid = Ext.extend(Ext.grid.GridPanel, {
initComponent:function() {
var config = {
store:new Ext.data.Store({
proxy: new Ext.data.HttpProxy(
new Ext.data.Connection({
url:'getalarm.htm'
})

),
reader:new Ext.data.JsonReader({
totalProperty:'total',
root:'rows',
fields: [
'alarmsId',
'severity',
'condType',
'remarks'
]
})
})
,columns: [
{header: "alarmsId", width: 170, sortable: true, dataIndex: 'alarmsId'},
{header: "severity", width: 170, sortable: true, dataIndex: 'severity'},
{header: "condType", width: 170, sortable: true, dataIndex: 'condType'},
{header: "remarks", width: 170, sortable: true, dataIndex: 'remarks'},
]

};


Ext.apply(this, Ext.apply(this.initialConfig, config));



MyGrid.superclass.initComponent.apply(this, arguments);
}

,onRender:function() {

// call parent
MyGrid.superclass.onRender.apply(this, arguments);

// load the store
this.store.load();

} // eo function onRender

});
Ext.reg('myGrid', MyGrid);




Main.js file code


Ext.onReady(function(){



var tabActions = new Ext.Panel({
frame:true,
title: 'Actions',
collapsible:true,
items:[{
xtype:'myGrid'
,id:'grid'
,title:'Grid'
,region:'center'
,layout:'fit'

}]
});

var win1 = new Ext.Window({
layout:'fit',
width:900,
height:450,
closable: false,
resizable: true,
plain: true,
border: true,
items: [tabActions]
});
win1.show();

});

How can i populate myGrid in main .js file.

Expecting valuable comments from all.
Thanks in advance

Condor
21 Jun 2010, 3:55 AM
What do you mean by 'populate'?

ps. Going by it's name, shouldn't tabActions be a TabPanel? If it isn't, then why do you even need tabActions? You could be using the grid directly!