user2211050
user2211050

Reputation: 139

How to declare a variable and increment inside a for loop for each iteration in Xtemplate

I'am using Extjs4.2.2. In my application i am using three loops, after the first loop i want to declare a variable and inside each iteration of second loop i want to increment the value and use the value in a class of a div. I have tried in the following way

'<tpl for="this.resources">',
'{% var parentIndex = xindex; %}',
'<tpl for="slots">',
                                '<div class="ext-cal-bg-row resource-slots-allocation tapaswini-'+(parentIndex++)+'" ></div>', // here i want to add the incremented value of parentindex to the class name tapaswini

'</tpl></tpl>',

But its giving error to me . Even am unable to access the "parentIndex" value.

Can anybody suggest where I'am missing. Any help is highly appreciated

Thanks in advance Tapaswini

Upvotes: 0

Views: 917

Answers (1)

user2211050
user2211050

Reputation: 139

I found the solution

'<tpl for="this.resources">',
'{% var parentIndex = xindex; %}',
'<tpl for="slots">',
   '<div class="ext-cal-bg-row resource-slots-allocation tapaswini-{[parentIndex++]} " ></div>', 
'</tpl></tpl>',

By this am able to increment the variable

Thanks Tapaswini

Upvotes: 1

Related Questions