【问题标题】:Is it possible to override columnDefs order in ag-grid angularjs?是否可以在 ag-grid angularjs 中覆盖 columnDefs 顺序?
【发布时间】:2016-06-06 08:00:55
【问题描述】:

是否可以在 ag-grid angularjs 中设置 columnDefs 索引值?

根据用户加载时间我需要改变col的顺序。

对于某些用户,我需要按此顺序显示网格数据。

在网格中 Col1:模型,Col2:价格,Col3:价格

对于某些用户,我需要按此顺序显示网格数据。

在网格中 Col1:价格,Col2:价格,Col3:型号

【问题讨论】:

    标签: javascript angularjs angularjs-scope ag-grid


    【解决方案1】:

    在 ag-grid.js 中替换这个函数

       ColumnController.prototype.extractRowGroupColumns = function () {
                var _this = this;
                this.rowGroupColumns = [];
                // pull out the columns
                this.allColumns.sort(function(a, b){
                 return a.colDef.seqNo-b.colDef.seqNo
                })
    
                this.allColumns.forEach(function (column) {
    
                    if (typeof column.getColDef().rowGroupIndex === 'number') {
                        _this.rowGroupColumns.push(column);
                    }
    
                });
                // then sort them
                this.rowGroupColumns.sort(function (colA, colB) {
                    return colA.getColDef().rowGroupIndex - colB.getColDef().rowGroupIndex;
                });
            };
    

    在标题数据中再添加一列名为 seqNo like

       $scope.gridheaders = [
                        {headerName: "ID", field: "ID", seqNo:0},
                        {headerName: "Patient Name", field: "PatientName", seqNo:1},
                        {headerName: "Gender", field: "Gender", seqNo:3},
                        {headerName: "Age", field: "Age", seqNo:2},
                        {headerName: "Phone Number", field: "mobileNumber", seqNo:4}
                    ];
    

    然后根据用户动态设置seqno...

    【讨论】:

      猜你喜欢
      • 2022-10-21
      • 2015-10-22
      • 2016-06-19
      • 2021-06-13
      • 2021-09-21
      • 1970-01-01
      • 2017-05-01
      • 1970-01-01
      • 2020-06-19
      相关资源
      最近更新 更多