Reputation: 1736
I am pushing multiple record to the table data by using id. Problem is its fetching only last record.
Inside the controller
for(var i=0;i<globalval.length;i++){
console.log("Inside for loop --->"+globalval[i].v1); -- > working
Ext.get('customerinfo').setHtml(globalval[i].v1);
}
VIEW
itemTpl:[
'<tr class="tbl">'
+ '<td id="customerinfo"></td></tr>'
+'</table>'
]
Upvotes: 0
Views: 151
Reputation: 5700
The mistake you are doing is that you have an array but in itemTpl
, you have not placed your XTemplate inside a loop. Do it like this:
itemTpl = new Ext.XTemplate(
'<tpl for=".">', // process the array
place your tpl structure here..
'</tpl>
);
------------------------------------------ EDITED -----------------------------------------------------------------------------------------
For example if the object from which you are supposed to fetch data is tableData
then iterate like this:
'<tpl for="tableData">',
'{name}: {value}, '
'</tpl>'
Upvotes: 1
Reputation: 1
You are setting a single cell (customerinfo) with the value of each record. Problem is that it's one single cell. It's like saying a = 1, then a = 2, then a = 3. Obviously at the end, a = 3.
Upvotes: 0