EXT列表中的其中一列,后台传过来的是JsonArray数组,如何获取这个数组中对象的某一个字段;
value的格式是:[{id : '1', name: '分类名称'}]
header : '分类', dataIndex : 'categorys', renderer : function(value) { if (Ext.isArray(value)) { var c = ''; Ext.each(value, function(item, index) { if (index > 0) { c += ', '; } c += item.name; }); return c; } }
其中,Ext.each方法是Ext.Array.each的别名。
Ext.each(Array/NodeList/Mixed array, Function(item, index){ // item表示前面所要迭代的数组的每一个元素。eg:如果数据是JSONArray形式的,item表示每一个json对象。 // index表示默认从0开始的item数组的索引位置 });