Hi Mike,
Although a JavaScript is possible, we would advice to use a Rocket MX script and event to handle this.
You will have various ways of solving this.
As you discovered, configuring the grid to sort by itself will only sort the data for the current page. Or, alternatively, the contents loaded in a variable. For instance when using the subfile collect functionality.
To sort on host level you have various options.
- Use a Container List instead of a grid
In the Container List you can configure a custom header and place buttons for the titles to sort (using theming you can make them appear as links or just text, just the way you like to see them).
On the button clicks you can configure the host field and an enter action so the button will place the cursor on the right place and sends an enter, and the host will do the sorting for you.
- Add an event to the grid for sorting, see the steps below.
When the host can do the sorting for you, as in your case, you can create an event in the grid to sort it in code.
To do so:
- Turn off the sorting for the grid columns, to avoid the grid sorting by itself, and this way rely on the sorting of the host system
- Create a script to handle the sorting
In the script you can use predefined variables such as: PanelFieldID, LBoxClickedRow, LBoxClickedColumn
The LBoxClickedRow will be -1 when the column is clicked (values 0 and up are for the first and subsequent rows)
The LBoxClickedColumn will contain the column number (0 for the first column, 1 for the second column, etc.)
In the script you can position the cursor on the right position and send the Enter key to execute sorting on the host.
- Link the script to the grid in the events tab of the properties view, as 'OnLeftClick'' event
- Now, when you left click the header, the script will be executed and sorting should be done from host level.
Hope this helps,
Regards,
------------------------------
Roger van Valen
Senior manager, software engineering
Rocket Software
Dordrecht, The Netherlands
------------------------------
Original Message:
Sent: 04-25-2023 12:33
From: Mike Warren
Subject: Clickable Grid Column Headers?
Subfiles in our green screen application often offer sorting that's triggered by cursor-sensitive column headers. Users can position the cursor on the header of the column that they'd like to use for sorting and press Enter. The application then sorts entirety of the subfile content, not just the visible page.
We need to figure out a way to support this functionality in MX Web such that it appears to be an integral part of Grid functionality so it's a more seamless experience that clicking a button that's independent of the Grid.
But is this possible? We figured out how to embed a button in a Grid header using HTML and the "Rich Mode" option, and we figured out how to make the button use JavaScript to trigger the correct host field. However, we haven't been able to style or size the button so that it takes the full width of the column or appears to blend into the column header. So, I wondered if we're going about this the right way, if there's something that might work better, or if what we're trying to achieve isn't possible?
------------------------------
Mike Warren
Software Development Manager, GOLD Team Leader
CU*Answers
Grand Rapids MI US
------------------------------