PDA

View Full Version : window not displaying on button click



talap01
26 Dec 2010, 11:55 PM
Hi Can somebody help me. i want to display different windows on click of button not as pop up window.
Here with attaching full code.
Attaching main.js is the first js file which will get loaded from my index.html
main js has two buttons.

this.mainPanel = new Ext.Panel({
region: 'center',
layout: 'fit',
border: false,
hidden:true,
id: 'mainPanel',
scope:this,
tbar: new Ext.Toolbar({
ctCls: 'lev2Nav',
items: [{
text: 'P&L Analysis (LOC)',
handler: this.onLOCAnalysis,
enableToggle: true,
id: 'pAndLAnalysis_loc',
name:'pAndLAnalysis_loc',
scope: this
}, {
text: 'P&L Analysis (USD)',
handler: this.onUSDAnalysis,
id: 'pAndLAnalysis_USD',
name:'pAndLAnalysis_USD',
scope: this,
enableToggle: true
}]
}),
listeners: {}
});


var viewport = new Ext.Viewport({
layout: 'border',
bodyStyle: 'background-color: white',
items: [ // appplication header
new Ext.BoxComponent({ // custom Header
region: 'north',
el: 'appHeader',
height: 45,
listeners: {
'render': function(){
this.utilTpl = new Ext.Template('<span>{username}</span><span>{options}</span><span>{login}</span><a href="#"><img src="../img/help.gif" name="help" width="16" height="16" border="0" align="absmiddle" id="help"></a>');
this.utilPanel = new Ext.Panel({
height: 24,
width: 350,
border: false,
tpl: this.utilTpl,
bodyStyle: 'background-color: transparent',
renderTo: 'appHeaderUtilities'
})
this.utilTpl.overwrite(this.utilPanel.body, this.guestUserInfo);
},
scope: this
}
}), this.mainPanel]
});

Ext.getBody().unmask();
return viewport;
},



on click of this buttons(P&L Analysis (LOC) & 'P&L Analysis (USD)',) in the same screen alternative i want to show different data in the window.

On success login i have attached "P&L Analysis (LOC)" to window. when i click on 'P&L Analysis (USD)' nothing is getting displayed.

handler code is as follows:

onLOCAnalysis: function(el){

alert('GlobalP&LLocal Analysis');

if (Ext.getCmp('globalPAndLUSDid')) {
Ext.getCmp('globalPAndLUSDid').hide();
}

if (!Ext.getCmp('globalPAndLLocalid')) {
alert('onDataEntryAnalysis inside if');
dataEntryLayout = new SME.SAMIS.GlobalP&LLocal();
}

SME.SAMIS.app.mainPanel.add(Ext.getCmp('globalPAndLLocalid'));
//SME.SAMIS.app.mainPanel.doLayout();
Ext.getCmp('globalPAndLLocalid').show();
Ext.getCmp('pAndLAnalysis_loc').toggle(true);
Ext.getCmp('pAndLAnalysis_USD').toggle(false);


},

onUSDAnalysis: function(el){
alert('pAndLAnalysis_USD');
debugger;
if (Ext.getCmp('globalPAndLLocalid')) {
Ext.getCmp('globalPAndLLocalid').hide();
}

if (!Ext.getCmp('globalPAndLUSDid')) {
alert('onSalesAnalysis object creation');
debugger;
this.salesAnalysis = new SME.SAMIS.GlobalPAndLUsd();
debugger;
SME.SAMIS.app.mainPanel.add(Ext.getCmp('globalPAndLUSDid'));
Ext.getCmp('globalPAndLUSDid').show();
Ext.getCmp('pAndLAnalysis_loc').toggle(false);
Ext.getCmp('pAndLAnalysis_USD').toggle(true);
//SME.SAMIS.app.mainPanel.doLayout();

}

else {
alert('globalPAndLUSD reusing existing object');
SME.SAMIS.app.mainPanel.add(Ext.getCmp('globalPAndLUSDid'));
// SME.SAMIS.app.mainPanel.doLayout();
Ext.getCmp('globalPAndLUSDid').show();
Ext.getCmp('pAndLAnalysis_loc').toggle(false);
Ext.getCmp('pAndLAnalysis_USD').toggle(true);
}


}


//Global P&LUSD.js

SME.SAMIS.GlobalPAndLUsd = function(config){

Ext.apply(this, config);
this.globalPAndLHeader = Ext.getCmp('globalPandLHeader');




SME.SAMIS.GlobalPAndLUsd.superclass.constructor.call(this, {
layout: 'border',
bodyStyle: 'background-color: white;',
border: false,
cls: 'forecast',
id: 'globalPAndLUSDid',
items: [this.globalPAndLHeader, new Ext.Panel({
region: 'center',
// margins: '0 5 5 5',
border: true,
layout: 'fit',
id: 'globalPAndLUsd',
// tbar: this.toolBar1,
//forecast utilities bar
items: [{
id: 'tot',
html: '<div id="totalsGridDiv" width="100%" height="100%"></div>'
}]
})],
listeners: {
render: function(tpan){
// debugger;
//if(document.getElementById("fcGridDiv").innerHtml==""){
totIO = new TDataIO();
debugger;
totIO.Data.Url = "GridData.xml";
totIO.Data.Timenout = 900;
totIO.Data.Sync = 3;
totIO.Upload.Type = 1;
totIO.Upload.Format = "Internal";
totIO.Upload.Data = "sendBack";
totIO.Upload.Method = "Soap";
totIO.Upload.Url = SME.SAMIS.app.sessionUrl + "w_upload_data/TOT";
totIO.Defaults.Timeout = 240;
totIO.Cache = 3;
TreeGrid(totIO, tag = "totalsGridDiv", id = "totalsGrid", 1, Sync = 3, Cache = 3);
Ext.getCmp('fcBody').purgeListeners();
//}
}
}
});

};




Ext.extend(SME.SAMIS.GlobalPAndLUsd, Ext.Panel, {

});




//Global P&L Local.js



SME.SAMIS.GlobalPAndLLocal = function(config){

Ext.apply(this, config);

this.artistTitleRecord = Ext.data.Record.create([{
name: 'artist-titleID',
type: 'string'
}, {
name: 'artist-titleName',
type: 'string'
}]);

this.artistTitleStoreUrl = 'ArtistTitleType.json'; //SME.SAMIS.app.sessionUrl + 'W_GET_DISTRIBUTION_TYPES';

this.artistTitleStore = new Ext.data.Store({
url: this.artistTitleStoreUrl,
reader: new Ext.data.JsonReader({
root: 'ARTIST-TITLE'
}, this.artistTitleRecord)
});

this.artistTitleStore.load();

this.artistTitleStore.on('load',function(artistTitleStore) {

Ext.getCmp('artistTitleCombo').setValue(artistTitleStore.getAt(0).get('artist-titleName'));
})


// TODO load options from server
menuUrl = SME.SAMIS.app.sessionUrl + 'w_batch/SILENT/W_APPL*GFDE/W_GETCOUNTRYLIST*' + SME.SAMIS.app.userId;
// menuUrl='../test.json';
// Ext.Ajax.disableCaching=false;
this.menuStore = new Ext.data.JsonStore({
autoDestroy: true,
proxy: new Ext.data.HttpProxy({
url: menuUrl,
// method: 'POST',
nocache: false,
prettyUrls: false
}),
reader: new Ext.data.JsonReader({
root: 'rows',
totalProperty: 'resultset',
idProperty: 'id',
fields: ['id', 'name', 'selectable']
}),
storeId: 'countryAccess',
fields: ['id', 'name', 'selectable']
});
this.menuStore.on({
'load': this.onforecastSelectorLoad
});
this.menuStore.on({
'exception': this.onforecastSelectorException
});
this.menuStore.proxy.on({
'loadexception': function(proxy, options, response, error){
debugger;
alert(error);
}
})

this.menuStore.load();

forecastSelector = new Ext.SplitButton({
cls: 'fcSelector',
width: 120,
align: 'left',
text: 'Please Select Country',
menu: new Ext.menu.Menu({
items: [{
text: 'Please Select Country',
disabled: true,
scope: this
}]
})
});


this.toolBar = new Ext.Toolbar({
//cls: 'toolbar-utilities',
cls: 'fcHeader',
id: 'toolBarid',
items: [{
xtype: 'tbspacer'
}, {
xtype: 'label',
text: ' ARTIST - TITLE: '
}, {
xtype: 'tbspacer'
}, {
xtype: 'combo',
bodyStyle: 'margin-right: 10px',
name: 'artisTitleCombo',
id: 'artistTitleCombo',
mode: 'local',
editable: false,
store: this.artistTitleStore,
displayField: 'artist-titleName',
valueField: 'artist-titleID',
typeAhead: true,
forceSelection: true,
triggerAction: 'all',
width: 250,
listeners: {
select: this.onDistributionTypeSelect,
scope: this
}
}]
});




this.globalPAndLHeader = new Ext.Panel({
region: 'north',
margins: '5 5 0 5',
border: false,
id: 'globalPandLHeader',
tbar: //forecast header bar
new Ext.Toolbar({
cls: 'fcHeader',
style: "border-bottom: none",
items: [forecastSelector, '-', {
text: 'Save',
iconCls: 'save-icon',
handler: this.onSaveFcData
}, {
text: 'Submit',
iconCls: 'submit-icon',
handler: this.onSubmit
}, '->', '-', {
text: 'Export to Excel',
iconCls: 'export-to-excel-icon',
handler: this.onExportExcel
}
]
})
});



SME.SAMIS.GlobalPAndLLocal.superclass.constructor.call(this, {
layout: 'border',
bodyStyle: 'background-color: white;',
border: false,
cls: 'forecast',
id: 'globalPAndLLocalid',
items: [this.globalPAndLHeader, new Ext.Panel({
region: 'center',
margins: '0 5 5 5',
border: false,
layout: 'fit',
id: 'fcBody',
tbar: this.toolBar,
//forecast utilities bar
items: [{
id: 'tot',
html: '<div id="totalsGridDiv" width="100%" height="100%"></div>'
}]
})],
listeners: {
render: function(tpan){
// debugger;
//if(document.getElementById("fcGridDiv").innerHtml==""){
totIO = new TDataIO();
totIO.Data.Url = "GridData.xml"
totIO.Data.Timenout = 900;
totIO.Data.Sync = 3;
totIO.Upload.Type = 1;
totIO.Upload.Format = "Internal";
totIO.Upload.Data = "sendBack";
totIO.Upload.Method = "Soap";
totIO.Upload.Url = SME.SAMIS.app.sessionUrl + "w_upload_data/TOT";
totIO.Defaults.Timeout = 240;
totIO.Cache = 3;
TreeGrid(totIO, tag = "totalsGridDiv", id = "totalsGrid", 1, Sync = 3, Cache = 3);
Ext.getCmp('fcBody').purgeListeners();
//}
}
}
});


express.sendRequest('W_GET_DATE_SET/S');
express.sendRequest('W_GET_DATE_SET/E');

};


Ext.extend(SME.SAMIS.GlobalPAndLLocal, Ext.Panel, {


onDistributionTypeSelect : function(combo, record, index) {

alert('on Select'+ combo.getValue() +'value ' + combo.displayField);

},

onSaveFcData: function(){
debugger;
otto = Grids["totalsGrid"].GetChanges();
alert(Grids["totalsGrid"].HasChanges());

Grids.OnDataSend = function(grid, iopart, senddata, func){
debugger;
alert(senddata);
};
Grids.OnAfterSave = function(grid, result){
debugger;
if (result == 0)
Ext.Msg.alert('Success', 'Data saved successfully!');
else
alert(result);
};
Grids.OnDataError = function(grid, code, mess, iopart, row){
debugger;
Ext.Msg.alert('Failure', 'Server reported: ' + code + '\n\n' + mess);
alert(mess);
};

if (Grids["totalsGrid"].HasChanges() == 1) {
Grids["totalsGrid"].Save();
}
alert('After Save!');
},

onReloadGrids: function(menuItem){
debugger;
refreshGrid = Grids['totalsGrid'];
totIO.Data.Url = SME.SAMIS.app.sessionUrl + "w_batch/SILENT/w_lmt_coun*" + menuItem.id + "/w_fill_fc_grid*TOT";
refreshGrid.Loading = 0;
refreshGrid.Reload(null, 'totalsGrid', false);

if (menuItem) {
SME.SAMIS.app.currCoun = menuItem.id;
forecastSelector.setText(menuItem.text);
}
},

onSubmit: function(){
this.ownerCt.ownerCt.ownerCt.onSaveFcData();
express.sendRequest('W_set_submit');

},

onforecastSelectorLoad: function(store, recs, opt){
//alert(store.reader.jsonData.resultset);
maxrow = store.reader.jsonData.resultset;
forecastSelector.text = store.reader.jsonData.rows[1].name;
for (i = 0; i < maxrow; i++) {
y = store.reader.jsonData.rows[i].selectable;
forecastSelector.menu.addMenuItem({
id: store.reader.jsonData.rows[i].id,
text: store.reader.jsonData.rows[i].name,
disabled: store.reader.jsonData.rows[i].selectable,
listeners: {
click: function(menuItem, e){
debugger;
//Check for Changes
if (Grids["totalsGrid"].HasChanges() || Grids["wwGrid"].HasChanges() || Grids["regGrid"].HasChanges() || Grids["locGrid"].HasChanges()) {
Ext.Msg.show({
title: 'Save Changes?',
msg: 'You have unsaved changes. Please save data first before changing Country!',
buttons: Ext.Msg.YESNO,
closable: false,
fn: function(button, text, opt){
debugger;
if (button == "yes" || button == "cancel") {
return;
}
refreshGrid = Grids['totalsGrid'];
totIO.Data.Url = SME.SAMIS.app.sessionUrl + "w_batch/SILENT/w_lmt_coun*" + menuItem.id + "/w_fill_fc_grid*TOT";
refreshGrid.Loading = 0;
refreshGrid.Reload(null, 'totalsGrid', false);
forecastSelector.setText(menuItem.text);

SME.SAMIS.app.currCoun = menuItem.id;
},
animEl: 'elId',
icon: Ext.MessageBox.QUESTION
});
}
else {
forecastSelector.ownerCt.ownerCt.ownerCt.onReloadGrids(menuItem);
}




//onForecastChange(menuItem.id);
}
}
//handler: function(){onForecastChange(store.reader.jsonData.rows[i].id);}
})
}
forecastSelector.activeItem = 1;
SME.SAMIS.app.currCoun = forecastSelector.initialConfig.menu.items.items[2].id;
forecastSelector.setText(store.reader.jsonData.rows[1].name);
//alert('After Load Event triggered!');
},
onforecastSelectorException: function(misc){
debugger;
alert('Errors occurred!');
},


onExportExcel: function(){
//dialog for simple or advanced export
expDlg = new SME.SAMIS.ExportType();
expDlg.showExportType();

}

});




other two classes are as follows attachement. which will be called on click of button.

Note: I have posted same type of question in this forum but no proper answer to resolve the issue
So i am posting as a newer one and expecting answers from some one.

jay@moduscreate.com
29 Dec 2010, 10:38 AM
that is a crap load of code for anyone to go through. What do you mean you want a window to show but not as a popup???

talap01
29 Dec 2010, 11:11 PM
Its the same issue, i have posted part by code. discussion happened. May be u will get to know by reading.
only variable declaration names are different. Please help me. I feel the way in which i am desigining is wrong..

http://www.sencha.com/forum/showthread.php?117892-onclick-want-to-show-tab-bar&p=547764#post547764