ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • #13 jQgrid - Column 동적 할당 및 Row 데이터의 Column명 변경
    JavaScript 2019. 11. 20. 17:00
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
                // data.DATASET.Table1.Column 경로의 ColoumnName 데이터 저장
                var columns= Dispatching.column(data.DATASET.Table1.Columns,"ColumnName","Alias");
                
                // 동적 컬럼 할당을 위함
                  if (gridOptions.colModel == null) {
                        var colModel = [];
                        $.each(columns, function (i, row) {
                            colModel[i] = {};
                            col = colModel[i];
                            col.name = row;
                            col.editable = true;
                            if (row == "QUERYSTRING") {
                                col.edittype = "textarea";
                            }
                            //col.width = "100%"
                        });
                        gridOptions.colModel = colModel;
                    }
                
               var rowData=Dispatching.rowsSet(data.DATASET.Table1.Rows,columns); // data.DATASET.Table1.Rows 경로의 컬럼명을 변경 
                  
                gridOptions["data"= rowData; // 바인딩
                gridOptions["datatype"= "local";
                gridOptions["beforeSelectRow"= null;
                gridOptions["ondblClickRow"= null;
                commonUtil.grid.set(grid2Table, gridOptions, null, callback);
                console.log(gridOptions);
                return;
            }
     
            commonUtil.grid.set(grid2Table, gridOptions, options, callback);
     
        },
        
        column: function (data, columnName, alias) {
            var result = {};
            $.each(data, function (key, value) {
                result[value[alias]] = value[columnName];
            });
            return result;
        },
        
        rowsSet: function (rows, column) {
            var results = [];
            $.each(rows, function (i, row) {
                result = {};
                $.each(row, function (key, value) {
                    result[column[key]] = value;
                });
                results.push(result);
            });
            return results;
    cs


    'JavaScript' 카테고리의 다른 글

    #12 Object에서 Key값 목록 나열하기  (0) 2019.11.20
    #6 자바스크립트 타입?  (0) 2019.06.17

    댓글

Designed by Tistory.