1
首先,非常感谢您在这里做的事情。这非常好。dojox.grid.EnhancedGrid中的数据排序
我正在开发一个带有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
。
任何解决方法? 在此先感谢。