PDA

View Full Version : Titles in Tabs from Mysql



Savaog
26 Apr 2012, 4:48 AM
Hello averyone!

i have a strange bug when open a window with Tab panels. Window has opened only after second click on a button.
Please help me in my situation.

Here is my code:


function showRepertuarWin(){

Ext.onReady(function(){

Ext.define('DaysModelGlobal', {
extend: 'Ext.data.Model',
fields: [
{name: 'text', type: 'string'},
{name: 'leaf', type: 'string'},
{name: 'id', type: 'string'}
]
});

var daystoreglobal = Ext.create('Ext.data.Store', {
autoLoad: true,
autoSync: true,
model: 'DaysModelGlobal',
storeId: 'DaysStoreGlobalID',
proxy: {
type: 'ajax',
url: 'config/months/dates_s_mCount.php',
actionMethods: {
create : 'POST',
read : 'GET',
update : 'POST',
destroy: 'POST',
},
reader: {
type: 'json',
root: 'result_m'
}
},
});
daystoreglobal.on('load', function(store, records) {

month0 = records[0].get('text');
month1 = records[1].get('text');
month2 = records[2].get('text');
month3 = records[3].get('text');
month4 = records[4].get('text');
month5 = records[5].get('text');


month0_parsed = Date.parse(month0);
month1_parsed = Date.parse(month1);
month2_parsed = Date.parse(month2);
month3_parsed = Date.parse(month3);
month4_parsed = Date.parse(month4);
month5_parsed = Date.parse(month5);
})




var winrepertuar = Ext.create('Ext.window.Window', {
height: 690,
width: 900,
title: '??????: ???????????? ????',
items: [
{
xtype: 'tabpanel',
activeTab: 0,
items: [
{
xtype: 'panel',
title: Ext.Date.format(new Date(month1_parsed), 'F Y')
},
{
xtype: 'panel',
title: Ext.Date.format(new Date(month2_parsed), 'F Y')
},
{
xtype: 'panel',
title: Ext.Date.format(new Date(month3_parsed), 'F Y')
},
{
xtype: 'panel',
title: Ext.Date.format(new Date(month4_parsed), 'F Y')
},
{
xtype: 'panel',
title: Ext.Date.format(new Date(month5_parsed), 'F Y')
}
]
}
]
});
winrepertuar.show();
})
}





and this is my JSON:



{success:true, "result_m": [{"text":"2012, 07, 01","leaf":"true","id":1},{"text":"2012, 08, 01","leaf":"true","id":2},{"text":"2012, 09, 01","leaf":"true","id":3},{"text":"2012, 10, 01","leaf":"true","id":4},{"text":"2012, 11, 01","leaf":"true","id":5},{"text":"2012, 12, 01","leaf":"true","id":6},{"text":"2013, 01, 01","leaf":"true","id":7},{"text":"2013, 02, 01","leaf":"true","id":8},{"text":"2013, 03, 01","leaf":"true","id":9},{"text":"2013, 04, 01","leaf":"true","id":10},{"text":"2013, 05, 01","leaf":"true","id":11},{"text":"2013, 06, 01","leaf":"true","id":12},{"text":"2013, 07, 01","leaf":"true","id":13}] }

Thanks for advise!
Regards,
Savaog

scottmartin
26 Apr 2012, 10:22 AM
It looks like your data has not made it back yet and your script has already moved on.
You would check your data return success before you decide to open your window.

Scott.

Savaog
27 Apr 2012, 12:59 AM
Hello again, Scott!

Glad to see you!

Yes i think about it, but i dont know how to make it correctly on my constuction.
Have you any idea to show me? I will be appreciate you efforts.

Thx alot!
Savaog.

vietits
27 Apr 2012, 1:09 AM
You should put the code of creating and showing your window inside the handler of store load event


daystoreglobal.on('load', function(store, records) {
month0 = records[0].get('text');
month1 = records[1].get('text');
month2 = records[2].get('text');
month3 = records[3].get('text');
month4 = records[4].get('text');
month5 = records[5].get('text');


month0_parsed = Date.parse(month0);
month1_parsed = Date.parse(month1);
month2_parsed = Date.parse(month2);
month3_parsed = Date.parse(month3);
month4_parsed = Date.parse(month4);
month5_parsed = Date.parse(month5);


var winrepertuar = Ext.create('Ext.window.Window', {
height: 690,
width: 900,
title: '??????: ???????????? ????',
items: [{
xtype: 'tabpanel',
activeTab: 0,
items: [
{
xtype: 'panel',
title: Ext.Date.format(new Date(month1_parsed), 'F Y')
},
{
xtype: 'panel',
title: Ext.Date.format(new Date(month2_parsed), 'F Y')
},
{
xtype: 'panel',
title: Ext.Date.format(new Date(month3_parsed), 'F Y')
},
{
xtype: 'panel',
title: Ext.Date.format(new Date(month4_parsed), 'F Y')
},
{
xtype: 'panel',
title: Ext.Date.format(new Date(month5_parsed), 'F Y')
}
]
}
]
});
winrepertuar.show();
});

I wonder what is the purpose of you use the code of Ext.read() inside function showRepertuarWin()?

Savaog
27 Apr 2012, 3:38 AM
Hello, vietits!

Your way is work fine! But after i need to check for multiple windows apears if i use refresh a store by taskmanager events.
It still not checked, so i post here later for results.

Thx for your advise! You help me almost on this step!

Savaog
27 Apr 2012, 3:40 AM
BTW, showRepertuarWin() is a function to call window from button in my HTML code.


<div id="ic_rplan" class="ic_kplan" align="center" onclick="showRepertuarWin();"><img src="images/icons/elegant/5.png" width="64" height="64" /><br /><strong>???????????? ????</strong></div>

Savaog