92
rated 0 times
[
94]
[
2]
/ answers: 1 / hits: 15121
/ 13 Years ago, mon, december 26, 2011, 12:00:00
Im trying to loop a array with extjs xtemplate and create a table
Ext.define('dataview_model', {
extend : 'Ext.data.Model',
fields : [
{name: 'count', type: 'string'},
{name: 'maxcolumns', type: 'string'},
{name: 'maxrows', type: 'string'},
{name: 'numbers', type: 'array'}
]
});
Ext.create('Ext.data.Store', {
storeId : 'viewStore',
model : 'dataview_model',
data : [
{count: '7', maxcolumns: '10', maxrows: '5', numbers: ['100','200','300','400','500','600','700']}
]
});
var tpl = new Ext.XTemplate(
'<tpl for=.>',
'<tpl if=count > 0>',
'<table class=view_table>',
'<tpl for=numbers>',
'<tr>',
'<td>{.}</td>',
'</tr>',
'</tpl>',
'</table>',
'</tpl>',
'</tpl>'
);
Ext.create('Ext.DataView', {
width : 500,
height : 200,
renderTo : Ext.getBody(),
store : Ext.getStore('viewStore'),
tpl : tpl
});
this is the working example which i have so far
what i want to do is stop the loop once there is 5 rows and add other values to second column like below
+----+ +----+
| | | |
+----+ +----+
+----+ +----+
| | | |
+----+ +----+
+----+
| |
+----+
+----+
| |
+----+
+----+
| |
+----+
any idea how to do this?
Thanks.
More From » extjs