0

I'm essentially wanting to implement a custom sort order. I have a list of items with a 'Status' choice column. The status choices are 'New Item', 'Funded', and 'Pending'. In my query, I'd like to order my data so that all items with a status of 'New Item' are grouped together and displayed first, then all 'Pending' items, then all 'Funded' items. I obviously cannot use basic asc or desc orderby functionality but I'm hoping there's a way to do this. I read about 'precedence grouping' here but unfortunately it is still a filter and not an 'orderby' query option. I'd really appreciate any insight that you may have! Thanks!

  • 1
    In this case I would think about ignoring the sort order while querying for the items, just make the REST call using whatever your filter and select criteria are, and then write a custom sort function to sort on those specific values in the way you want, and just use that to sort the items before you display anything. – Dylan Cristy Dec 18 '18 at 0:53
2

Just Throwing down my options

I am thinking the easier option would be to create a calculated column in SharePoint based on the Status field that specifies the order you want.

New Item = 0 , Pending = 1

Now, use your existing REST API Query to have ASC on the Calculated Column

or

Try Using SharePoint REST API with CAML Queries to perform the grouping and then let javascript to process the data and display accordingly.

or

Send in Separate REST API Call for each status and display them.

2

You can have a additional column - Single line of text / calculated coloum which stores numerical value for each status value e.g. New Item will have 1 , Funded will be have 2 and so on.

Further the REST API will return results based on the numerical value.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.