1
votes

in my JSON structure I have an object :

[{ id: 1, name: xxxxx, operation1: { startdate: 2011-10-25, enddate: 2011-11-25 }, operation2:{......}}]

in order to display the operations date, I need to access to stardate and enddate but how ?

I tried

{header:'operation1', xtype:'templatecolumn', tpl:'<span>{operation1.startdate}</span>', align:'center'}

in fact, I create columns dynamically :

for(var i=1;i<=31;i++){
  this.columns.push({header:i, xtype:'templatecolumn', tpl:'<span>{operation'+i+'.startdate}</span>', align:'center'});
}
1
Typo? The tpl:'<span>{'+i+'.startdate}</span>' yields tpl:'<span>{1.startdate}</span>', tpl:'<span>{2.startdate}</span>'... etc.Lionel Chan
yes sorry, It's a mistake : tpl:'<span>{operation'+i+'.startdate}</span>'Cyril F
Problem solved? Could you share a little bit more so we know what's wrong with it :) cheers!Lionel Chan
No, problem isn't solved. I fact, if an user has no operation number 2 for example, It doesn't work. I need to put in Json all operations even they don't exist ?Cyril F
Either you set it as empty (to prevent errors), or use XTemplate's useful methods to do the value checking.Lionel Chan

1 Answers

2
votes

Most probably you forgot to add operation1 into your fields. Check out this working demo

fields: ['id', 'name', 'operation1', 'operation2']