前端之家收集整理的这篇文章主要介绍了
DOJO遍历DataGrid数据并转换成json格式数据,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
var length = grid.store._arrayOfAllItems.length;
//循环遍历合同信息,并修改合同信息(修改状态、支数和重量)
for(var i = 0;i<length;i++){
//取得主键
var id = grid.store.getValue(grid.getItem(i),"id");
//取得合同信息
var conId = grid.store.getValue(grid.getItem(i),"constractId");
var materialNumber = grid.store.getValue(grid.getItem(i),"materialNumber");
var materialWeight = grid.store.getValue(grid.getItem(i),"materialWeight");
var contract ='{"id":"'+id+'","constractId":"'+conId+'","materialNumber":"'+materialNumber+'","materialWeight":"'+materialWeight+'"}';
//将合同转换为object对象
var strObj = Json.parse(contract,true);
//将object转换为json对象
var strJson = Json.stringify(strObj);