如何在App Maker中按月对列表进行排序? [英] How can I sort a list by month in App Maker?
问题描述
我想按月在App Maker中对列表进行排序,但我不知道如何进行排序.
I want to sort a list in App Maker by month, and I don't know how to it.
我认为是这样,但事实并非如此.
I think that was the way, but is not.
@datasource.item.MONTH#sort()
推荐答案
我不确定有多少方法可以实现这一目标,但是有两种方法:
I am not sure how many ways there are to achieve this but here are two ways:
第一个:转到模型数据源并更改排序选项以反映月份,然后按升序或降序进行选择.请参见下面的示例.
First one: Go the the model datasource and change the sorting option to reflect the month and then choose by ascending or descending. See the example below.
第二个:选择表小部件,然后转到属性编辑器中的事件部分.单击 onDataLoad 事件,然后输入以下代码:
Second one: Select the table widget and the go to the events section in the Property Editor. Click on the onDataLoad event and type the following code:
widget.datasource.items.sort(
function(a, b) {
if (a.Month > b.Month) {
return 1;
} else {
return -1;
}
}
);
请参见下图:
您偏爱哪种方式,都是您的选择.希望对您有帮助!
Whichever way you prefer, is your choice. Hope it helps!
注意:第二个选项将仅对当前加载到客户端的具有单个页面的记录进行排序.
Note: the second option will sort only records withing single page currently loaded to the client.
这篇关于如何在App Maker中按月对列表进行排序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!