I have a datagrid with multiple columns. The user is able to sort on every column they see using default datagrid sorting. Is it possible to save the sort order or the sorting attribute from the users input? I want to use it later on from the detail page to go to next or previous item from that same order.
Find the data grid DOM elements on the page
Get a reference to the actual data grid widget object
Get the current sorting setting on the data grid as a string
Return that string
The code would need to look like this (note: this code is not fully tested but worked from my browser console):
// input parameter gridClass: a string matching a CSS class applied to the data grid on the page
var dgNode = document.getElementsByClassName(gridClass);
var dg = dijit.registry.byNode(dgNode);
// outputs a string that looks like this:
(sorry about the formatting above… something is up with the code editor)
This is not possible using out of the box functionality. You will have to create custom functionality to achieve this.
Couple of options that I can think of are (not sure if it works but may need some trails)
Custom logic / functionality
Create a SortingHelper entity and all the sort columns as attributes, associate this entity to your main entity and user account.
Add SortingHelper entity as a context entity of the page and retrieve data grid as association (create or retrieve this SortingHelper entity and associate it to a user in the microflow that opens this page).
Add custom button above required columns of data grid to sort (style them accordingly)
Add onchange event on each sort button and apply logic to retrieve and sort based on user selection, set SortingHelper_YourMainEntity association and persist the user selection.
Look into creating custom widget similar to data grid that includes all your requirements can be another option.