1

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

我正在使用 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'];
}

问题?我不能按状态(status's name)排序,它只有product.id在我单击状态标题时才会排序。

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

4

1 回答 1

1

我相信您需要添加clientSort="true"以启用客户端排序。将此添加到<table>声明中。

于 2011-08-04T05:37:57.857 回答