Pass current datagrid2 sort to microflow

0
Is there a way to get the current sort state from a datagrid2 inside of a microflow?   The reason being is I have a datagrid2 with a microflow datasource because there is some complicated logic. Because of the large amount of data and the complex logic, I need to implement my own custom paging. Setting an offset isn’t hard. I just make sure the datagrid2 has some context and that parent object has an offset field, and I can change this offset myself and re-trigger the microflow, (adding or subtracting 1 to the offset). However, if the sorting changes, then I have a problem. I can have a retrieve that has a custom amount of records with an offset and size, but the sorting is sort of hard coded into the retrieve widget. I can set multiple retrieves with different sorting, with a decision before them and only go down the path that matches the datagrid’s current sort, but I just need to know what the sort is. Right now I can only think of adding extra parent object fields for sorting and then setting them with javascript when the datagrid sorting headers are set. But it just seems like a lot of work.
asked
2 answers
1

Hey Bryan, 

If you go with server side paging, you should probably also do this for the sorting.

To do this, disable default sorting inside DG2, and add sort buttons to the datagrid 2 widget (perhaps in the header) and create an attribute to select the sorting type (ascending or descending). Then do the sorting inside the data source microflow. 

answered
1

Hey Brian,

if this is still a issue, check the "Personalization" -> "Configuration" -> "Attribute" on your DataGrid2.

image.png

There select a string(unlimited) attribute of your context entity. When in a microflow check the value of this attribute. There will be "sort":true somewhere in that string, there just check to which column that belongs (there's a "column":"ColumnName" somewhere infront of the sort part) and you got the correct column/attribute to sort by. You can also read the "sortDirection" in that string to differentiate between ASC/DESC.

If you need any more advice feel free to ask.

BR

Syman

answered