【问题标题】:Data sorting in a dojox.grid.EnhancedGriddojox.grid.EnhancedGrid 中的数据排序
【发布时间】:2011-08-02 01:47:07
【问题描述】:

首先,非常感谢您在这里所做的一切。太好了。

我正在使用 Dojo 开发一个 Web 应用程序,但我遇到了在 dojox.grid.EnhancedGrid 中排序我的行的问题。 假设我有一个产品状态为产品,我的 JSON 文件如下所示:

[
  {"id":1,"name":"Car A","price":"1000","productstatus":{"id":1,"name":"new"}},
  {"id":2,"name":"Car B","code":"2000","productstatus":{"id":2,"name":"old"}}
]

我想将这些数据放入我的网格中,并通过单击标题来更改行的顺序。

我的 HTML 文件中有:

<table id="lstProduct" jsId="lstProduct" dojoType="dojox.grid.EnhancedGrid" >
  <thead>
    <tr>
      <th field="id">Id</th>
      <th field="name" width="100px">Name</th>
      <th field="price" width="100px">Price</th>
      <th field="id" formatter="formatterStatus">Status</th>
    </tr>
  </thead>
</table>

还有我的 Javascript 文件:

dojo.addOnLoad(function() {

  productStore = new dojo.data.ItemFileReadStore({data: { items: ${products} }});
  dijit.byId("lstProduct").setStore(productStore);

});

// formatter
function formatterStatus(val, rowIndex) {
  return lstTasks.getItem(rowIndex)['productstatus'][0]['name'];
}

问题?我不能按状态排序(状态的name),当我单击状态标题时,它只能按product.id 排序。

有什么解决方法吗? 提前致谢。

【问题讨论】:

    标签: javascript dojo dojox.grid dojox.grid.datagrid


    【解决方案1】:

    我相信您需要添加clientSort="true" 才能启用客户端排序。将此添加到 &lt;table&gt; 声明中。

    【讨论】:

      猜你喜欢
      • 2014-10-05
      • 1970-01-01
      • 1970-01-01
      • 2012-01-03
      • 1970-01-01
      • 1970-01-01
      • 2017-08-20
      • 2018-08-16
      • 1970-01-01
      相关资源
      最近更新 更多