Yii Framework Forum: How to sort API expand fields ? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How to sort API expand fields ?

#1 User is offline   overload 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 28-June 12

Posted 05 September 2016 - 06:19 PM

Hi All,

I built a REST API to get a list of books
http://localhost/api/web/v1/books


and get the details of each book by id
http://localhost/api/web/v1/book/7


In this last call, I added chapters in extra fields
http://localhost/api/web/v1/book/7?expand=chapters


but my chapters are sort in a bad way in the database :/
Do you have a solution to sort by default all related chapters ?

I tried
http://localhost/api/web/v1/book/7?expand=chapters&sort=title,number
http://localhost/api/web/v1/book/7?expand=chapters&sort=number

with no success...

Any help will be appreciated.

Thanks in advance.
0

#2 User is offline   chandran 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 558
  • Joined: 08-October 12
  • Location:Austria

Posted 30 September 2016 - 05:32 AM

View Postoverload, on 05 September 2016 - 06:19 PM, said:

Hi All,

I built a REST API to get a list of books
http://localhost/api/web/v1/books


and get the details of each book by id
http://localhost/api/web/v1/book/7


In this last call, I added chapters in extra fields
http://localhost/api/web/v1/book/7?expand=chapters


but my chapters are sort in a bad way in the database :/
Do you have a solution to sort by default all related chapters ?

I tried
http://localhost/api/web/v1/book/7?expand=chapters&sort=title,number
http://localhost/api/web/v1/book/7?expand=chapters&sort=number

with no success...

Any help will be appreciated.

Thanks in advance.


you have to use like this ... - for desc
GET v1/users?sort=-priority,status
Thanks
chandran nepolean

My own extension:
http://www.yiiframew...sion/ejqueryte/
http://www.yiiframew...uallistboxyii1/

My wiki
http://www.yiiframew...checkboxcolumn/

If it work dont hesitate to click +1 button
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users