首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

ExtJs学习之路-从Grid中失去数据

2012-10-07 
ExtJs学习之路--从Grid中得到数据function GetJSON(grid, colm, k) {??????? var rowCount grid.getStor

ExtJs学习之路--从Grid中得到数据


function GetJSON(grid, colm, k) {

??????? var rowCount = grid.getStore().getCount();
??????? var JSONArray =new Array();
??????? var colCount = colm.getColumnCount();
??????? for (var i =0; i < rowCount; i++) {
??????????? var JSONObjStr ="{";
??????????? for (var j = k; j < colCount; j++) {
??????????????? var colName = grid.getColumnModel().getDataIndex(j);
??????????????? var tempObj = grid.getStore().getAt(i).get(colName);
??????????????? tempObj = (tempObj +"").replace(/(^\s*)|(\s*$)/g, "");
??????????????? tempObj = tempObj.replace(/\\/g, '\\\\');
??????????????? tempObj = tempObj.replace(/"/g, '\\"');???????????????

tempObj = tempObj.replace(/\'/g, '\\\'');
??????????????? // tempObj = tempObj.replace(/\b/g, '\\b');???????????????

tempObj = tempObj.replace(/\r/g, '\\r');
??????????????? tempObj = tempObj.replace(/\n/g, '\\n');
??????????????? tempObj = tempObj.replace(/\t/g, '\\t');
??????????????? tempObj = tempObj.replace(/\f/g, '\\f');
??????????????? if (j == k) {
??????????????????? JSONObjStr +=''+ colName +':'+'"'+ tempObj +'"';
??????????????? } else {
??????????????????? JSONObjStr +=','+ colName +':'+'"'+ tempObj +'"';
??????????????? }
??????????? }
??????????? JSONObjStr +="}";
??????????? JSONArray.push(Ext.util.JSON.decode(JSONObjStr));
??????? }
??????? return Ext.util.JSON.encode(JSONArray);
??? }

?

热点排行