我正在尝试将数据库中的产品展示到devexpress phonejs中的tileview项目中。成功地我可以将数据源中的项目加载到tileview中,但我想按类别名称对项目进行分组,并且真的不知道怎么做。任何帮助将不胜感激。
JS代码
return {
sale: sale,
departmansSource: {
store: PosApplication.db.Departmans,
select: ["DepartmanID", "DepartmanName"]
},
categoriesSource: {
store: PosApplication.db.Categories,
select: ["CategoryID", "CategoryName"]
},
productsSource: {
store: PosApplication.db.Products,
filter: ["DepartmanID","=", 2],
select: ["ProductID", "ProductName", "DepartmanID", "DepartmanName", "CategoryID", "CategoryName"]
},
approversSource: {
store: PosApplication.db.Approvers,
select: ["ApproverId", "ApproverName"]
},
handleSave: handleSave,
handleCancel: handleCancel,
viewShown: handleViewShown,
notifiy: notifiy
};
Html代码
<div id="urunlertile" data-bind="dxTileView: { height: '550', dataSource: productsSource, itemClickAction: notifiy, baseItemHeight: 70, baseItemWidth: 150, itemMargin: 3, }">
<div data-options="dxTemplate:{name:'item'}">
<p><span data-bind="text: $data.CategoryName"></span></p>
<p><span data-bind="text: $data.ProductName"></span></p>
</div>
</div>
</div>
答案 0 :(得分:0)
您可以使用postProcess回调对dataSource中的数据进行分组/排序。
请注意,dxTileView不支持显示分组数据。对数据进行分组,如
[{ key: "Category1", items: [{ name: "Product1" }, ...], ...]
您可以在项目模板中放置嵌套的dxTileView以显示每个类别的产品。