• 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);
        }

  • 相关阅读:
    前端万字面经——进阶篇
    canvas 爬坑路【属性篇】
    Linux下提权反弹脚本
    修改和重置WAMP的phpMyAdmin密码
    如何调试Apache的URL重写(转载收藏)
    sharepoint 计算列的公式
    SharePoint控件的使用
    快速查看dll的PublicToken。
    DataCogsFieldControls 有时保存不上的问题
    遍历文件中的资源
  • 原文地址:https://www.cnblogs.com/chjw8016/p/1850154.html
Copyright © 2020-2023  润新知