【问题标题】:how can I make a column unsortable when using the dojo toolkit's grid?使用 dojo 工具包的网格时,如何使列无法排序?
【发布时间】:2010-09-27 14:31:34
【问题描述】:

我有一个不想排序的网格 (dojox.grid v1.2)。我怎样才能禁用它?

【问题讨论】:

    标签: datagrid dojo


    【解决方案1】:

    找到了:

    http://dojotoolkit.org/forum/dojox-dojox/dojox-grid-support/disable-sorting-specific-column-0

    保存链接:

    在您的 onload 或 postrender 中添加如下代码:

    dojo.byId('myGridId').canSort = function(col){ if(Math.abs(col) == 3) { return false; } else { return true; } };

    (注意,在此设置中,列似乎从 1 开始索引。)

    【讨论】:

      【解决方案2】:

      如果您以编程方式创建网格,您可以执行以下操作:

      var grid = new dojox.grid.DataGrid({ 
                     ..., 
                     canSort: function(col) { return col != 3; }
                 });
      

      【讨论】:

        【解决方案3】:

        使用属性canSort : false 隐藏或禁用Dojo DataGrid 代码中的排序按钮:

        var newGrid = new DataGrid({
        
                id : 'newGrid',
        
                canSort:false,
        
                store : this.resultStore,
        
                structure : this.resultGridLayout,
        
                autoHeight:true
        });
        

        问候,

        Satish M Hiremath

        【讨论】:

          【解决方案4】:

          我认为正确的解决方案是

          dijit.byId('yourgridid').attr('canSort', function(col){
          
              if(Math.abs(col) == 3) {
                return false;
              } else {
                 return true;
              }
          
          });
          

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2011-02-20
            • 1970-01-01
            • 2011-10-13
            • 1970-01-01
            相关资源
            最近更新 更多