d007
17 Sep 2011, 7:03 AM
If I have an array of unknown data, how can I tell extjs to loop through the data and generate a template based on what is inside the data.
So I have an array with values item1, item2, item3,..., item 50
My current template does an if statement for every single possible item like this:
'<tpl for=".">',
'<tpl if="item1">',
'<span>{item1}</span>',
'</tpl>',
'<tpl if="item2">',
'<span>{item2}</span>',
'</tpl>',
etc
Which I am thinking is very inefficient as I have a lot of items to check for. Whereas if I could loop through 'array' which has only the items that were sent to the store from the server it would be better.
How can I accomplish this? Thanks
So I have an array with values item1, item2, item3,..., item 50
My current template does an if statement for every single possible item like this:
'<tpl for=".">',
'<tpl if="item1">',
'<span>{item1}</span>',
'</tpl>',
'<tpl if="item2">',
'<span>{item2}</span>',
'</tpl>',
etc
Which I am thinking is very inefficient as I have a lot of items to check for. Whereas if I could loop through 'array' which has only the items that were sent to the store from the server it would be better.
How can I accomplish this? Thanks