PDA

View Full Version : replace panel content with new content



mnask79
3 Nov 2009, 7:37 AM
hi all ,

i have tapPanel have many tabs ..in every tab there is a gridPanel

the initial value for the grid8 content is , coz i dont want to load the js files if the end use will not use it



var grid8 = {id:'customermap-div-id',html:'test test ttest',title:'customer map',listeners: {activate: function(){
autoloadJSFiles({
fn:'test',
jsFile:'js/cus-map.js'
});
}}} ;





tabP = new Ext.TabPanel({
activeTab: 0,
id: 'customer-detail-tab',
title: fullname +' ( account # '+accNo +' - status:'+ status +')',
items:[customerInfo_MainePanel,cNotes,manageServicesTabssss,managePayment_MainePanel,bwlog,cpelog_panel,VC_panel,grid8]
});

and i dont want to load all js script till the end user click on the tab . so once the end use click on the tab i call the following function to autoload the tab content js file



function autoloadJSFiles (objJSFile){
if ( loadedScripts.indexOf( objJSFile.jsFile ) < 0 ) {
loadedScripts.push(objJSFile.jsFile);
Ext.Ajax.request({
url: objJSFile.jsFile,
success: function ( res ) {
if ( res && res.responseText ) {
eval( res.responseText );
eval( window );

}
},
failure: function () {
alert( "we couldn't load the js" );
}

});
}
}



as u see i load the js file then eval it
and the script is


var myData = [
['3m Co',71.72,0.02,0.03,'9/1 12:00am'],
['Alcoa Inc',29.01,0.42,1.47,'9/1 12:00am'],
['Altria Group Inc',83.81,0.28,0.34,'9/1 12:00am'],
['American Express Company',52.55,0.01,0.02,'9/1 12:00am'],
['American International Group, Inc.',64.13,0.31,0.49,'9/1 12:00am'],
['AT&T Inc.',31.61,-0.48,-1.54,'9/1 12:00am'],
['Boeing Co.',75.43,0.53,0.71,'9/1 12:00am'],
['Caterpillar Inc.',67.27,0.92,1.39,'9/1 12:00am'],
['Citigroup, Inc.',49.37,0.02,0.04,'9/1 12:00am'],
['E.I. du Pont de Nemours and Company',40.48,0.51,1.28,'9/1 12:00am'],
['Exxon Mobil Corp',68.1,-0.43,-0.64,'9/1 12:00am'],
['General Electric Company',34.14,-0.08,-0.23,'9/1 12:00am']
];

var store = new Ext.data.ArrayStore({
fields: [
{name: 'company'},
{name: 'price', type: 'float'},
{name: 'change', type: 'float'},
{name: 'pctChange', type: 'float'},
{name: 'lastChange', type: 'date', dateFormat: 'n/j h:ia'}
]
});
store.loadData(myData);

grid8 = new Ext.grid.GridPanel({
id:'customermap-div-id',
store: store,
columns: [
{id:'company',header: "Company", width: 160, sortable: true, dataIndex: 'company'},
{header: "Last Updated", width: 85, sortable: true, dataIndex: 'lastChange'}
],
stateful : true ,
frame:false,
border:false,
layout:'fit',
viewConfig:{
forceFit:true
},
stripeRows: true,
loadMask : true ,
autoWidth : true ,
height : 394 ,
title:' Customer Map'
});



so my problem , i dont know how to replace the content of people when i load the js file

i hope u got me ,, please help me guys