thejdog
20 Sep 2007, 9:24 AM
Ok, I've been having issues with getting this working for days. And I know I'm doing something wrong. I have searched many times on here for GridPanel and haven't found something that can really demonstrate what I'm needing.
I have this code that is doing a AJAX call and getting JSON data:
function buildSponsorTabs () {
sponsorTabPanel = new Ext.TabPanel('center-tabs');
Ext.Ajax.request({
url: 'urlurlurl',
success: function ( r, o) {
var sponsorList = Ext.util.JSON.decode( r.responseText );
for( var i = 0; i < sponsorList.length; ++i ) {
var sponsorId = sponsorList[i].Id
sponsorTabs[sponsorId] = sponsorTabPanel.addTab( sponsorId+'-stats', sponsorList[i].Name+' Stats');
sponsorTabs[sponsorId].on('activate', statsGrid );
}
sponsorTabPanel.activate( sponsorList[0].Id+'-stats' );
},
failure: function () {
Ext.Msg.alert('Error', 'Please try again in a few moments.');
}
})
}
Then I have it making making the data sources, columnModel, grid & grid panel:
function statsGrid( tabPanel, tab ) {
var sponsorId = tab.id.split("-");
var sponsorId = sponsorId[0];
statsData = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url: 'urlurlurlurl' }),
reader: new Ext.data.JsonReader({
root: 'results',
id: 'site',
totalProperty: 'total',
aggregate:['none','total', 'sum', 'sum']
}, [
DATA SOURCE INFO WENT HERE
])
});
statsData.load({
params:{
s: sponsorId,
o: 'getStats'
}
});
statsColumnModel = new Ext.grid.ColumnModel([
COLUMN MODEL WAS HERE
]);
// alert( Ext.id() );
var statsGridPanelId = Ext.DomHelper.append(tab.id, {tag:'div', id:Ext.id()}, true);
var statsGridId = Ext.DomHelper.append(statsGridPanelId.id, {tag:'div', id:Ext.id()}, true);
var statsGrid = new Ext.grid.Grid( statsGridId.id, {
ds: statsData,
cm: statsColumnModel,
selModel: new Ext.grid.RowSelectionModel({singleSelect: true}),
loadMask: {msg: "Loading Stats Data List..."},
monitorWindowResize: false,
maxHeight: 500,
autoHeight: true
});
var gridLayout = new Ext.BorderLayout.create({
center: {
margins:{left:3,top:3,right:3,bottom:3},
panels: [new Ext.GridPanel(statsGrid)]
}
}, tab.id);
statsGrid.render();
}
I'm setting the Element for the Ext.BorderLayout.create to be the tab's body id and then I'm making a new div/id for the grid itself inside of the tab.id div (from what I believe).
Now the issue I'm having is that the gird is showing up, but it seems that because the tabs are taking up the space up top, I'm losing that much of the grid on the bottom.
What would be the proper way to do this do you think?
I have this code that is doing a AJAX call and getting JSON data:
function buildSponsorTabs () {
sponsorTabPanel = new Ext.TabPanel('center-tabs');
Ext.Ajax.request({
url: 'urlurlurl',
success: function ( r, o) {
var sponsorList = Ext.util.JSON.decode( r.responseText );
for( var i = 0; i < sponsorList.length; ++i ) {
var sponsorId = sponsorList[i].Id
sponsorTabs[sponsorId] = sponsorTabPanel.addTab( sponsorId+'-stats', sponsorList[i].Name+' Stats');
sponsorTabs[sponsorId].on('activate', statsGrid );
}
sponsorTabPanel.activate( sponsorList[0].Id+'-stats' );
},
failure: function () {
Ext.Msg.alert('Error', 'Please try again in a few moments.');
}
})
}
Then I have it making making the data sources, columnModel, grid & grid panel:
function statsGrid( tabPanel, tab ) {
var sponsorId = tab.id.split("-");
var sponsorId = sponsorId[0];
statsData = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url: 'urlurlurlurl' }),
reader: new Ext.data.JsonReader({
root: 'results',
id: 'site',
totalProperty: 'total',
aggregate:['none','total', 'sum', 'sum']
}, [
DATA SOURCE INFO WENT HERE
])
});
statsData.load({
params:{
s: sponsorId,
o: 'getStats'
}
});
statsColumnModel = new Ext.grid.ColumnModel([
COLUMN MODEL WAS HERE
]);
// alert( Ext.id() );
var statsGridPanelId = Ext.DomHelper.append(tab.id, {tag:'div', id:Ext.id()}, true);
var statsGridId = Ext.DomHelper.append(statsGridPanelId.id, {tag:'div', id:Ext.id()}, true);
var statsGrid = new Ext.grid.Grid( statsGridId.id, {
ds: statsData,
cm: statsColumnModel,
selModel: new Ext.grid.RowSelectionModel({singleSelect: true}),
loadMask: {msg: "Loading Stats Data List..."},
monitorWindowResize: false,
maxHeight: 500,
autoHeight: true
});
var gridLayout = new Ext.BorderLayout.create({
center: {
margins:{left:3,top:3,right:3,bottom:3},
panels: [new Ext.GridPanel(statsGrid)]
}
}, tab.id);
statsGrid.render();
}
I'm setting the Element for the Ext.BorderLayout.create to be the tab's body id and then I'm making a new div/id for the grid itself inside of the tab.id div (from what I believe).
Now the issue I'm having is that the gird is showing up, but it seems that because the tabs are taking up the space up top, I'm losing that much of the grid on the bottom.
What would be the proper way to do this do you think?