1.
var jsonData = Ext.encode(Ext.pluck(store.data.items, ‘data‘));
2.
var datar = new Array(); var jsonDataEncode = ""; var records = store.getRange(); for (var i = 0; i < records.length; i++) { datar.push(records[i].data); } jsonDataEncode = Ext.util.JSON.encode(datar);
项目中需要将添加的积分兑换奖品列表传给后台,用到第一种方法,可行。
Share.AjaxRequest({ url : ‘fen/chargefen‘, params : { listdata : Ext.encode(Ext.pluck(grid.getStore().data.items, ‘data‘)), loadname : btn.up("window").loadname }, callback : function() { btn.up("window").close(); } });
Plucks the value of a property from each item in the Array. Example:
Ext.Array.pluck(Ext.query("p"), "className"); // [el1.className, el2.className, ..., elN.className]
Available since: 4.0.0
The Array of items to pluck the value from.
The property name to pluck from each element.
The value from each item in the Array.
原文:http://www.cnblogs.com/linruiyi2015/p/4974602.html