Rocket Modern Experience (formerly LegaSuite)

 View Only
  • 1.  Clickable Grid Column Headers?

    Posted 04-25-2023 12:51

    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
    ------------------------------


  • 2.  RE: Clickable Grid Column Headers?

    ROCKETEER
    Posted 04-26-2023 03:22
    Edited by Roger Van Valen 04-26-2023 03:22

    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
    ------------------------------



  • 3.  RE: Clickable Grid Column Headers?

    PARTNER
    Posted 04-26-2023 09:37

    Everything Roger said...
    Our package works the same...  my code has some custom functions..

    ' GridSelect - Determine if user is Sorting on Header or Submitting selection via OIS Variables.
    Dim hfn As String 
    Dim hfv, hfl As Integer 

    If (EventNr = 24) And (ListBoxClickedRow = - 1) Then ' LMouseButtonClick on Heading for Sort
        hfn = "H" + Str(ListBoxClickedColumn + 1)' HostField Name of Heading
        If miscFieldVerify(hfn) Then ' Expecting H1, H2, H3...
            HostFieldGetProp(hfn, 5, hfv)' Property 5 = Color
            If (hfv = 24) Or (hfv = 26) Or (hfv = 28) Or (hfv = 30) Then ' S2K sortable colors: 26=Blue/Black 30=Blue/Black underline 24=Magenta/Black 28=Magenta/Black underline
                HostFieldGetProp(hfn, 8, hfv)' Height
                hfl = hfv - 1 ' Line Number starts at zero - RPG Sort typically only works on bottom line for double headings
                HostFieldSendKey(hfn, hfl, "Enter")' Submit sort
            EndIf 
        EndIf 
    EndIf 

    If (EventNr = 25) And (ListBoxClickedRow >= 0) Then ' LMouseButtonDblClick on a Row for Submit
        ScriptCall("HKEnter")' Typically navigating away, use script to send Enter then collect function keys
    EndIf 



    ------------------------------
    Leon Brown
    Gui Developer
    Vormittag Associates Inc
    Ronkonkoma NY US
    ------------------------------