getting sorted items from grid - Typescript

Is there a way to get an array of sorted items from the Grid?

Hi,
I have a Grid component in which I can sort on different columns.
After for ex. “the active element changed”, I need an array of all the grid elements, in the exact order resulted from the sorting config.

Something like grid.sortedItems?

Is there anything like that available?

Thank you in advance for your time!

Check the DataView API. The setItems method returns instance of DataView for you.

Thanks Tatu, but I’m afraid you would have to explain it more in detail . I should mention I am using hilla with typescript.

getting sorted items from grid - Typescript

@secure-leopard any late night suggestions ? :slightly_smiling_face:

Update: I am currently achieving this functionality in a very over engineered way and I would prefer more direct solution :slightly_smiling_face:

Can you show the code for your grid and data provider

I should mention I am using hilla with typescript.
Thanks for that, DataView API is available only in Java. There is no API in TypeScript in Grid to get that list. The internal list is not public. But as pointed by Marcus, if you use dataProvider instead of binding to items property, you need to sort the items in data provider callback, so you have naturally the array there and you can expose it to your application.

Thank you!