Page 1 of 2
Sorted display of listItems
Posted: Wed Jul 23, 2014 6:02 pm
by Cody Blue
I intend items from Appery backend to be display in reverse chronological order of their creation timestamp in Appery DB. I am using sort field as Request parameter for REST service (screenshot attached). However, the list items are not getting sorted as expected. and the order is erroneous.Could you suggested a solution.?
Many thanks.
Sorted display of listItems
Posted: Wed Jul 23, 2014 7:21 pm
by Evgene Karachevtsev
Hello Cody,
Could you please clarify what js code you've added to the parameter?
Sorted display of listItems
Posted: Wed Jul 23, 2014 8:56 pm
by Cody Blue
Hi Eugene,
It is - return('-_createdAt'); Without it I get erroneous results as well.
Thanks.
Sorted display of listItems
Posted: Thu Jul 24, 2014 2:41 am
by Yurii Orishchuk
Hi Cody,
I see problem on your screen shot:
See details on screen shot: http://prntscr.com/45qu1y/direct
So, you need to use following code instead of yours:
pre
return '_createdAt';
/pre
Or remove "-" character from "-_createdAt" value.
Regards.
Sorted display of listItems
Posted: Thu Jul 24, 2014 4:48 am
by Cody Blue
Thank you Yurii. "-" characed is actually valid (to ensure "reverse" chronological order with time stamps). That said, I just realize it was my mistake. I should have used "-_updatedAt" field, which is the behavior I was instead expecting to achieve.
Thanks again.
Sorted display of listItems
Posted: Thu Aug 07, 2014 6:17 pm
by xman
I have one query service, but that is called on 2 different pages. Both pages have different sort requirements.
One list display is sorted by event's date, the other event display is sorted by event's time.
How can I use sort with 2 different criteria on 2 different pages (when they use the same service)?
Sorted display of listItems
Posted: Thu Aug 07, 2014 7:29 pm
by xman
never mind, figured out! All I need is to modify JS for the sort request param on each page.
Sorted display of listItems
Posted: Thu Aug 07, 2014 7:30 pm
by Evgene Karachevtsev
Hello Xman,
Thank you for the update.
Sorted display of listItems
Posted: Thu Aug 07, 2014 7:51 pm
by xman
Still have a question though, sorting by string works fine, but sorting by a column whose type is "Date" in database is not working for me.
Sorted display of listItems
Posted: Thu Aug 07, 2014 9:42 pm
by Yurii Orishchuk
Hi XMAN,
At first you need to know that you have one service but two datasources on two pages. You can edit datasource for each page in accordance to your needs.
Also, i've tested sorting by date type column and it seems to be ok.
Please take a look on screen shot: http://prntscr.com/4alffn/direct
Provide us screen shot where we can see how do you test it.
Regards.