简体   繁体   English

如何在App Maker中按月对列表进行排序?

[英]How can I sort a list by month in App Maker?

I want to sort a list in App Maker by month, and I don't know how to it. 我想按月对App Maker中的列表进行排序,但我不知道如何进行排序。

在此处输入图片说明

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. 请参见下面的示例。 在此处输入图片说明

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: 单击onDataLoad事件,然后键入以下代码:

widget.datasource.items.sort(
  function(a, b) {
    if (a.Month > b.Month) {
      return 1;
    } else {
      return -1;
    }
  }
);

See the image below: 见下图: 在此处输入图片说明

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. 注意:第二个选项将仅对当前加载到客户端的具有单个页面的记录进行排序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM