Plex 2E

 View Only
Expand all | Collapse all

WinC: Get grid sorting columns and sort direction

  • 1.  WinC: Get grid sorting columns and sort direction

    Posted May 16, 2016 09:30 AM

    Is there a WinC api function for getting information about which columns are used to sort a grid and what direction is used? I know of the WINAPI function SortGrid, but it seems that there is not a function for getting current sort settings.

     

    My scenario: I would like to run Reload grid for a grid, but retain the current ordering.



  • 2.  Re: WinC: Get grid sorting columns and sort direction

    Posted May 16, 2016 10:24 AM

    dynamic column sort see my answers

     

    You up against winwidgets so you can always look at http://wiki.plexinfo.net/index.php?title=WinWidgets .  I have for you and in the help there is no reference to determining if a column has or has not be sorted and if so ascending or descending.

     

    BUT that does not mean winwidgets does not support it as in WIDGETS.H  in your CA Plex Headers folder you will see the following:

     

    // Grid Sorting
    #define HGM_SORTGRID (HGM_FIRST + 133)
    #define HGM_SETGRIDSORTMODE (HGM_FIRST + 134)
    #define HGM_RESORTGRID (HGM_FIRST + 135)
    #define HGM_GETCURRENTSORTSTATE (HGM_FIRST + 136)
    

     

    Now you could play with HGM_GETCURRENTSORTSTATE  as it is not clear what it does or indeed the parameters...maybe you send in the control name and column number and it sends back sorted yes no and ascending or descending or not...i don't know with out playing..it might just tell you if a particular column can be sorted ie sorting is enabled on the coloumn

     

    You would play around with something like the following:

    {
     HWND hwndGrid=ObPanelAPI::GetControlHandleByName(&(1:));
     if (hwndGrid)
     {
      SendMessage(hwndGrid,HGM_GETCURRENTSORTSTATE,?????,0);
     }
    }
    


  • 3.  Re: WinC: Get grid sorting columns and sort direction

    Posted May 16, 2016 10:31 AM

    if not as highlighted others

    see http://edge.plexinfo.net/?action=edge&forum=479&thread=30523#MessageId94240

    and  http://edge.plexinfo.net/?action=edge&forum=480&thread=29917#MessageId91589

     

    People have a hidden the column headings and used buttons instead to mimic the column headings (which are buttons) and then you have full control on the grid.

     

    Lazy Yuk Tip: Have seen others add a hidden counter to a grid and if the order changes then some sorting has occured..



  • 4.  Re: WinC: Get grid sorting columns and sort direction

    Posted May 16, 2016 12:03 PM



  • 5.  Re: WinC: Get grid sorting columns and sort direction

    Posted May 16, 2016 03:39 PM

    Was trying to help you for several hours but CA Plex cr!p build standard these days I could not get Source code: WINAPI/Re-SortGrid  to work....Source code: WINAPI/SortGrid works. Wanted to make sure these worked before as a stable platform to look at HGM_GETCURRENTSORTSTATE

     

    My advice is contact support and ask why WINAPI/Re-SortGrid does not work and while you are at it ask what does HGM_GETCURRENTSORTSTATE do. Good Luck



  • 6.  Re: WinC: Get grid sorting columns and sort direction

    Posted May 16, 2016 04:12 PM

    When playing with HGM_GETCURRENTSORTSTATE and using the tagSortInfo structure I found it was crashing the plex runtime which to help CA support reminded me of the problem I had with the structure in C++ Client Testing Tool Support of WinWidgets Grid



  • 7.  Re: WinC: Get grid sorting columns and sort direction

    Posted May 17, 2016 02:34 AM

    Thank you for help!

     

    I do not yet know what solution to try, but I can report when I get my functionality implemented.

     

    The workaround for this could be that I just update the changed row in the grid, and so I would not need to do the reloading of grid. I just don't know it is possible to handle deletion of a grid row that way.



  • 8.  Re: WinC: Get grid sorting columns and sort direction
    Best Answer

    Posted May 17, 2016 04:03 AM

    You can delete just a row with out reloading just use the remove statement



  • 9.  Re: WinC: Get grid sorting columns and sort direction

    Posted May 17, 2016 05:12 AM

    Ok, I'll try that solution.

     

    Thanks a lot for studying this.



  • 10.  Re: WinC: Get grid sorting columns and sort direction

    Posted May 17, 2016 05:26 AM

    No worries my pleasure, I gave up late late last night, my hacking of c++ is not good enough. I suspect it wont work but need a c++ person to confirm. Lets hope wink wink jeremy can help jstent1.1

     

    // http://www.cplusplus.com/forum/windows/57382/
    typedef struct tagSortInfo
    {
      int iColumnNumber;
      BOOL bAscending;
    }
    SORTINFO,*LPSORTINFO;
    
    
    
    
    
    
    
    
    {
     HWND HwndGrid=ObPanelAPI::GetControlHandleByName(&(1:));
     if (HwndGrid)
     {
      SORTINFO *ptr_test;
      SendMessage(HwndGrid,HGM_GETCURRENTSORTSTATE,(WPARAM)ptr_test,NULL);
     }
    }
    


  • 11.  Re: WinC: Get grid sorting columns and sort direction

    Posted May 17, 2016 05:32 AM

    pretty please JeremyStent



  • 12.  Re: WinC: Get grid sorting columns and sort direction

    Posted May 17, 2016 12:38 PM

    I cannot find any documentation on this message.  I can get it to call the message without fouling up the calling thread.  We need CA (in the absence of the original winwidgets developers) to give us some documentation on the parameters and expected results of this windows message.  (Parameters are *Object with the grid control name, then FirstSortColumn, FirstSortSeq, SecondSortColumn, SecondSortSeq, ThirdSortColumn, and ThirdSortSeq). Columns appear to be 0 based..

    {

         SORTINFO * sInfo;

         LRESULT lr;

         HWND hwndGrid = ObPanelAPI::GetControlHandleByName(&(1:));

         if (hwndGrid)

         {

              lr = SendMessage(hwndGrid, HGM_GETCURRENTSORTSTATE, 0, (WPARAM) &sInfo); // changing the 0 to something else seems to have no impact

              // lr seems to be the number of sort columns.  User clicking only ever seems to set 1.  Programmatically we can set at least three.

              if (lr > 0) // at least one sort column

              {

                   &(2:) = sInfo[0].iColumnNumber;

                   &(3:) = sInfo[0].bAscending;

              }

              else

              {

                   &(2:) = -1;

                   &(3:) = TRUE;

              }

              if (lr >1) // at least two sort columns

              {

                   &(4:) = sInfo[1].iColumnNumber;

                   &(5:) = sInfo[1].bAscending;

              }

              else

              {

                   &(4:) = -1;

                   &(5:) = TRUE;

              }

              if (lr > 2) // at least three sort columns, probably specified programmatically

              {

                   &(6:) = sInfo[2].iColumnNumber;

                   &(7:) = sInfo[2].bAscending;

              }

              else

              {

                   &(6:) = -1;

                   &(7:) = TRUE;

              }

         }

         else

         {

              // Grid not found.

         }

    }



  • 13.  Re: WinC: Get grid sorting columns and sort direction

    Posted May 17, 2016 02:10 PM

    cool, I have always tried to hunt down the Winwidgets helpfile latter than v2.0. Have not tried that hard as I could always send the developers an email from their linkedin...so zero real marks for effort..infact will do as I am bored of learning java today...

     

    I can confirm the columns are zero based and there is only 3 possible columns that can be sorted at any one time so your guess work on the parameters are a good as we could guess.

     

    i spent hours last night and all i needed was '&' next to my pointer field! Dont know what & does differently just will add it to my hacks to try when writing c++ source code!

     

    This was meant to be impossible according to CA in yester year so it is shame I didn't have the experience/confidence a decade ago to solve these things etc...I kinda relied/believed on everyone else....wont make the same mistake now with Outsystems/Mule etc, thanks again Jeremy and nice collaboration.



  • 14.  Re: WinC: Get grid sorting columns and sort direction

    Posted May 17, 2016 02:34 PM

    Found the founder of winwidgets and will email him to see if he has a help file lying around!

     

    Founder

    Simple Software, Inc.

    1992 – 1996 (4 years)

    • Designed, developed and marketed the WinWidgets™, an extensive set of GUI components used by Windows developers around the world.
    • Licensed WinWidgets and other proprietary technology to Siemens, KnowledgeWare, Microsoft, Symantec, Morgan Stanley and others.
    • Grew a development and support organization to 6 people.



  • 15.  Re: WinC: Get grid sorting columns and sort direction

    Posted May 17, 2016 05:49 PM

    Prefacing a variable with an ampersand ('&') gets the address of the variable.  With the address the functions that is called can modify the data, otherwise it can just reference the data passed in, and not change what is seen by the calling program.  We pass the address to the pointer to the winwidget, and it changes the value of the pointer to point to some array.  Without documentation I cannot say if we are supposed to free any memory afterwards.

    There is also a concern that someone may have clicked on a column heading, and then reloaded the grid.  In this case the grid might think it is sorted on that column, but it has really not since the data would be in the load order.  It is also possible that someone clicked on a description, and then a status.  This function call would return the status as the sort column, but would not indicate that there had been a secondary sort on the description, so if we re-applied the sort we would not sort in the same order.



  • 16.  Re: WinC: Get grid sorting columns and sort direction

    Posted May 17, 2016 11:16 AM

    It seems that using using Set and Remove statements to refresh the grid is a working solution. One question still arised: how can one add a new row to grid?

     

    Is it something like this?

     

    Set Grid2P = Invoices.Fetch.SingleFetch/FetchedData

    Insert

    Refresh Grid2P



  • 17.  Re: WinC: Get grid sorting columns and sort direction

    Posted May 17, 2016 02:16 PM

    Set Grid End Off  Grid2P

    Set Grid2P = Invoices.Fetch.SingleFetch/FetchedData

    Append Grid2P

    Set Grid End On  Grid2P

    Refresh  Grid2P

    Locate Grid2P



  • 18.  Re: WinC: Get grid sorting columns and sort direction

    Posted May 17, 2016 02:20 PM

    You need to use your action diagram palette more....... you need to sit down and look at all the Grid action diagram statements and look at plex help for all of them. When you are trying to get 'good' at plex you need to know what all the action  diagram palette options are. There are not so many psedo code action diagram statements and unlike other languages it has not been expanded or advanced (shame pity etc) on so you really dont have much to learn compared with evolving languages where you never really catch up....easy to become truly expert in plex as I did as it remains constant...

     

    You need to use the APPEND statement as you can see from the action diagram palette

     

    Untitled.png