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

依然范特西╮ 提交于 2020-01-06 06:03:24

问题


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()

回答1:


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:

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.



来源:https://stackoverflow.com/questions/48805877/how-can-i-sort-a-list-by-month-in-app-maker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!