zoukankan      html  css  js  c++  java
  • 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);
        }

  • 相关阅读:
    linux下的第一个C程序及其编译方法
    使用open_read_write等底层函数来赋值一个文件
    C++中预定义的宏
    altibase MDB的创建sequence的举例
    C中的时间函数的用法
    联系表单 1
    《jQuery基础教程》读书笔记
    《jQuery基础教程》读书笔记
    《jQuery基础教程》读书笔记
    『原创·翻译』如何阅读论文
  • 原文地址:https://www.cnblogs.com/chjw8016/p/1850154.html
Copyright © 2011-2022 走看看