PDA

View Full Version : populate year and month value from Json formate with XTemplate in tabler format



ranjay
24 Jan 2011, 4:17 PM
Hello All,
I tried to populate data from sample( datastore) in a tabler formate using XTemplate in Extjs.
My problem is infact i am unable to get data from two label at a time like
in payment profile i can read if {2005, "","", "" }.
But, I have to deal with nesting and 2 lavel one will provide a year other will provide value corresponding to month.
Please help me out. I am new for XTemplate. Below i have provided datastore(sample ) as well as structure how i want data.
Thanks in advance .

var sample = {
"TradeLine": {
"tradelines": {
"Accounts": [
{"SubscriberDisplayName": "abc",
"PaymentProfile": {
"2005": {
"1": "0",
"2": "0",
"3": "1",
"4": " ",
"5": " ",
"6": " ",
"7": " ",
"8": " ",
"9": " ",
"10": " ",
"11": " ",
"12": " "
},
"2004": {
"1": "0",
"2": "0",
"3": "-",
"4": "0",
"5": "0",
"6": "0",
"7": "0",
"8": "0",
"9": "0",
"10": "0",
"11": "0",
"12": "0"
}
}},
{"SubscriberDisplayName": "abc",
"PaymentProfile": {
"2000": {
"1": "3",
"2": "2",
"3": "3",
"4": " ",
"5": " ",
"6": " ",
"7": "7",
"8": " ",
"9": " ",
"10": " ",
"11": " ",
"12": " "
},
"2001": {
"1": "0",
"2": "0",
"3": "-",
"4": "0",
"5": "0",
"6": "0",
"7": "0",
"8": "0",
"9": "0",
"10": "0",
"11": "0",
"12": "0"
}
}}
]
}}};







var tpl1 = new Ext.XTemplate(
'<table cellspacing="1" >',

'<tr>',
'<th><div class="pagekey"><a href="http://www.experian.com/products/pdf/glossary_alpha_v8.pdf" target="_blank" title="View Payment History definitions">Key</a></div></th>',
'<th>Jan</th>',
'<th>Feb</th>',
'<th>Mar</th>',
'<th>Apr</th>',
'<th>May</th>',
'<th>Jun</th>',
'<th>Jul</th>',
'<th>Aug</th>',
'<th>Sep</th>',
'<th>Oct</th>',
'<th>Nov</th>',
'<th>Dec</th>',
'</tr>',
'</table>');
tpl1.overwrite("form-ct2", sample.TradeLine.tradelines.Accounts);
});


How to display data in the Sample in table formate like

Jan Fab Mar Apr May Jun Jul Aug Sep Oct Nov Dec
2005 0 0 1
2006 0 0 0 0 0 0 0 0 0 0 0



Jan Fab Mar Apr May Jun Jul Aug Sep Oct Nov Dec
2000 3 2 3 7 0 1
2001 0 0 0 0 0 0 0 0 0 0 0