【问题标题】:Dojo EnhancedGrid nested sorting not workingDojo EnhancedGrid 嵌套排序不起作用
【发布时间】:2011-04-14 18:28:58
【问题描述】:

我正在尝试在 Dojo 中创建具有嵌套排序功能的增强网格,但是当我通过插件添加嵌套排序功能时,网格不再在页面中工作(显示)。我的增强网格创建代码如下:

dojo.require("dojox.grid.EnhancedGrid");
dojo.require("dojox.grid.enhanced.plugins.NestedSorting");
grid = new dojox.grid.EnhancedGrid({
        canSort: function(colIndex) {
            //colIndex = -colIndex; //make columns decend 
            if ((colIndex == colA) || (colIndex == colB)) {
                return false;
            }
            return true;
        },
        onHeaderCellMouseOver:function(event{onGridHeaderCellMouseOver(event,layout[0]);},
        onHeaderCellMouseOut: function(event){onGridHeaderCellMouseOut(event,layout[0]);},
        store: msgStore,
        structure: layout,
        plugins: {nestedSorting: true}
    },document.createElement("div"));
    dojo.byId("TableHolder").appendChild(grid.domNode);
    grid.startup();
    grid.setSortInfo(-1);

如果我注释掉插件行,那么它会在没有嵌套排序的情况下完美运行。有谁知道我将如何获得嵌套排序功能? 我正在使用 Dojo 1.4。 谢谢

【问题讨论】:

    标签: javascript sorting datagrid dojo


    【解决方案1】:

    应该是早期版本的缺陷,它在 1.5 中对我有用,也是 dojo forum 的相关线程

    【讨论】:

      【解决方案2】:

      似乎我已经解决了这个问题....我发现必须包含“必需”的文件是:“dojox.grid.cells.dijit”。奇怪的是,我从文档中没有发现任何迹象表明这是必要的,但确实在示例中找到了它。一旦这被添加到我需要的语句中,我就有了嵌套排序。有人能解释一下这个特定的要求及其看似至关重要的重要性吗?

      谢谢

      【讨论】:

      • 您可能希望添加您的 dojo.require 调查结果和“有人可以解释要求...”作为对您问题的编辑。它会给您的解决方案和后续问题更多的可见性。干杯。 (P.S. +1 澄清 Dojo 文档的任何内容。)
      【解决方案3】:

      刚刚快速尝试了 1.4.3,似乎相同的代码对我有用:

      dojo.addOnLoad(function(){
          var grid = new dojox.grid.EnhancedGrid({
              id:'grid',
              canSort: function(colIndex) {
                  if ((colIndex == 0) || (colIndex == 1)) {
                      return false;
                  }
                  return true;
               },
               onHeaderCellMouseOver:function(event)onGridHeaderCellMouseOver(event,layout[0]);},
              onHeaderCellMouseOut: function(event)onGridHeaderCellMouseOut(event,layout[0]);},
              store: csvStore1,
              structure: layout,
              plugins : {nestedSorting: true}
          }, document.createElement("div"));
          dojo.byId("gridDiv").appendChild(grid.domNode);
          grid.startup();
          grid.setSortInfo(-1);  });
      

      它在您的 onHeaderCellMouseOver:function(event{ 中格式不正确,但不要认为这是原因,因为单排序适合您。

      顺便说一句,在 1.4 中不支持通过 grid.setSortInfo(-1) 设置默认嵌套排序顺序(它在 1.6 的计划中)

      【讨论】:

        猜你喜欢
        • 2012-08-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-03-31
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多