Sorting\Ordering OData Views
If you have an OData table, is there an easy way to order the contents via a specific column?
I have a custom view for Business Services with the filter: ?$filter=(StatusId ne null).
Just wondering if there is a simple way of adding a sort function on the DisplayName.
Best Answer
-
Justin_Workman Cireson Support Super IT Monkey ✭✭✭✭✭
@Sean_Terry - You can use the odata $orderby operator. I just tried this in one of my widgets. I ordered by Title by adding this to the Query String: ?$orderby=Title
You can string them together with the & sign:
?$filter=(Title ne null)&$orderby=Title
There is a lot of good info about odata operations here: https://www.odata.org/documentation/odata-version-2-0/uri-conventions/ They may not all work with the query string in the widget, but it's a good guide for figuring out what's available.
0
Answers
@Sean_Terry - Sorting in the grid works for me in an odata widget. Is it not working for you or are you just talking about pre-sorting?
@Justin_Workman Thanks for the reply. Pre sorting if that's possible? I've grabbed the filter from the out of the box CMDB pages, but I wasn't sure if another command can be bolted on to pre sort?
@Sean_Terry - You can use the odata $orderby operator. I just tried this in one of my widgets. I ordered by Title by adding this to the Query String: ?$orderby=Title
You can string them together with the & sign:
?$filter=(Title ne null)&$orderby=Title
There is a lot of good info about odata operations here: https://www.odata.org/documentation/odata-version-2-0/uri-conventions/ They may not all work with the query string in the widget, but it's a good guide for figuring out what's available.
@Justin_Workman Thank you!! Works a treat.