问题
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