Cody Blue
Posts: 0
Joined: Sun Aug 25, 2013 2:11 am

Sorted display of listItems

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.

Image

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Sorted display of listItems

Hello Cody,

Could you please clarify what js code you've added to the parameter?

Cody Blue
Posts: 0
Joined: Sun Aug 25, 2013 2:11 am

Sorted display of listItems

Hi Eugene,

It is - return('-_createdAt'); Without it I get erroneous results as well.

Thanks.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Sorted display of listItems

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.

Cody Blue
Posts: 0
Joined: Sun Aug 25, 2013 2:11 am

Sorted display of listItems

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.

xman
Posts: 0
Joined: Sun Jul 06, 2014 7:05 pm

Sorted display of listItems

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

xman
Posts: 0
Joined: Sun Jul 06, 2014 7:05 pm

Sorted display of listItems

never mind, figured out! All I need is to modify JS for the sort request param on each page.

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Sorted display of listItems

Hello Xman,

Thank you for the update.

xman
Posts: 0
Joined: Sun Jul 06, 2014 7:05 pm

Sorted display of listItems

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.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Sorted display of listItems

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.

Return to “Issues”