Skip to main content
venkateshg4665
July 17, 2025
Question

Sort In Readonly grid

  • July 17, 2025
  • 6 replies
  • 0 views

Hi everyone,

There is a read-only grid that uses a record-type data source. The table structure is as follows: Request Id (Primary Key) Name (varchar) In the grid filters, I’m applying a filter on the Request Id using the IN operator, and passing the values {9, 5, 3}. However, the grid displays the results in sorted order as {3, 5, 9}. I want the grid to display the records in the same sequence as the values I pass in the filter — i.e., {9, 5, 3} — without sorting them. How can I achieve this?

Thanks in advance !

6 replies

stefanhelzle0001
July 17, 2025

A database or record query will not return the data in such a specific order.

You need to query the data separately into a local variable. Then you can iterate on the PKs and fetch the items from the result set in that order. Then you can feed that final list into the grid.

venkateshg4665
July 17, 2025

Thank you for your reply [mention:a11f77a729fb4db2af76b09948583328:e9ed411860ed4f2ba0265705b8793d05]  if we use data source as one local variable then export excel will not work 

stefanhelzle0001
July 17, 2025

True. But if you need this, I do not see any option to implement your requirement.

mikes0011
Brainy
July 17, 2025

You would need to add a new column to your DB table (and/or to your record type) that determines the sort order, apart from the primary key ID.  Usually I've seen this sort of column named "ordinal" or similar, and just contains sequential integer values (i.e. 1, 2, 3), and the query can sort by that by default instead of sorting on a different column value.

venkateshg4665
July 21, 2025

Thank you for your reply [mention:b45a4f6a20b14a008e4e0ec732a8bf98:e9ed411860ed4f2ba0265705b8793d05] ,i didn't get what you are trying to say

mikes0011
Brainy
July 22, 2025

i'm saying you can handle sorting in queries by adding a new / separate column, which would hold sequential numbers (i.e. 1 - 3 in your case), ordered per how you want the results to come back.  such a column would usually be named "ordinal" or maybe "sort order" (the name doesn't matter much as long as its intention is clear).  this also enables you to change the default queried order in the future without having to "fix" how the elements are queried onto interfaces.