I have a field (single line of text) with some values

using this query below

var RestUrl = _spPageContextInfo.webAbsoluteUrl + "/_api/Web/Lists/GetByTitle('Books')/items?$top=6&$select=Title,Number&$orderby=Number asc&$filter=startswith(Number,'" + Num + "')";

I get this output 6.0, 6.11, 6.11.1,,, but what i want is :- 6.0,, 6.11, 6.11.1, Any ideas i can achieve this if the field is not a number?


1 Answer 1

  1. Your data is formatted as x.y.z, and you need 3 ordering rules: x ascending, then y ascending, then z ascending. You could use 3 columns to store x, y and z. You would apply the sorting criteria, and for rendering you would use a calculated column: =x+"."+y+"."+z

  2. If it's too many columns to handle, then you would have to use the 00.00.000 format.

  3. If you don't want to do this manually, you can omit orderby clause while getting the data. Once you have the data, add it in array and sort it using jquery.

  • Thanks Deepmala what would be the formula for the calculated column. Also what do you mean by the format 00.00.000?
    – naijacoder
    Nov 28, 2017 at 12:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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