Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Sorting a grid

  1. #1
    Member
    Join Date
    Apr 2013
    Posts
    88

    Sorting a grid

    Hi, how to have sorted data into a grid (without using a custom section) ? Also, saw there is a "sort" method for Grid but did'nt manage to use it ...
    Regards

  2. #2
    Lianja Team yvonne.milne's Avatar
    Join Date
    Feb 2012
    Location
    Berkshire, UK
    Posts
    1,379
    You could do something like this:

    Name:  runtime.jpg
Views: 102
Size:  107.5 KB

    The Page has a Form Section with its height set just large enough to display its Custom Menu and all header buttons hidden. Below that is a Grid Section with its header hidden. This is it in Development View:

    Name:  development.jpg
Views: 105
Size:  126.7 KB

    The Form Section Custom Menu switches the index tag order of the Customers table and refreshes the Grid, causing it to be sorted in the selected order. Here's the code:

    Name:  code.jpg
Views: 97
Size:  73.3 KB

    Regards,

    Yvonne

  3. #3
    Member
    Join Date
    Apr 2013
    Posts
    88
    Many thanks, I'll inspire me from this example!

  4. #4
    Member
    Join Date
    Apr 2013
    Posts
    88
    After realizing indexes were needed and disappeared at exit, i was able to sort columns in first grid, but as I was doing this for another grid in another page it fails ...
    Wed Jun 5 16:47:46 2013
    **** Lianja error ****
    tag STATS_PROVINCE_PROVINCENAME

    ^
    No table is in USE

    This very table being used for this grid ...
    Called from procedure - province_sort_customsectionmenu at line 5

    list stats_province shows

    Production DBX file: stats_province.dbx
    Index TAG: STATS_PROVINCE_PROVINCENAME
    Key: PROVINCENAME
    Type: Character
    Len: 58
    Any way out?
    Regards

  5. #5
    Lianja Team yvonne.milne's Avatar
    Join Date
    Feb 2012
    Location
    Berkshire, UK
    Posts
    1,379
    Is that the currently selected table? In my sample I only have one table/cursor open, so I have not included any SELECT statements to select the correct cursor. With more than one table, save the currently selected cursor and reselect it after changing the index tag order.

    Index tags are required for each of the sort orders here and can be created at the Console using the NoSQL INDEX command or the SQL CREATE INDEX command. Once created, index tags exist in the basename.dbx file, so should not need to be recreated. Let us know if you are having a problem with this.

    Regards,

    Yvonne

  6. #6
    Senior Member
    Join Date
    Feb 2012
    Posts
    1,214
    Hi Yvonne,

    This is a clever idea, but I think its more intuitive to allow us to put the code in the grid column header. Maybe even in the current click event if the row number = -1 type of thing.

    Herb

  7. #7
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    5,771
    Hi Herb, please submit an ER for a HeaderClick delegate and I'll implement an inline delegate that switches the order. The only pre-requistite with all this is that indexes you create must be prefixed by the child key.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  8. #8
    Member
    Join Date
    Apr 2013
    Posts
    88
    Hi, can't figure out to do that ... I have 2 tables in 2 different pages and 2 delegates to specify the order
    proc page1_Sort_customsectionmenu()
    set order tag T1_NAME
    Lianja.getElementById("Page1.T1List").refresh()
    endproc
    proc Page2_Sort_customsectionmenu()
    set order tag T2_NAME
    Lianja.getElementById("Page2.T2List").refresh()
    endproc
    sort on 1st table is ok.
    When sorting on 2nd table
    **** Lianja error ****
    tag T2_NAME

    ^
    TAG not found
    Called from procedure - page2_sort_customsectionmenu at line 4

    Modified delegate for T2 with a use statement
    proc Page2_Sort_customsectionmenu()
    USE T2
    set order tag T2_NAME
    Lianja.getElementById("Page2.T2List").refresh()
    endproc
    error is now
    **** Lianja error ****
    T2

    ^
    ALIAS name 'T2' already in use
    Called from procedure - page2_sort_customsectionmenu at line 4
    It is not apparently the way to "select the correct cursor" ...
    Regards

  9. #9
    Lianja Support Team lianjasupport's Avatar
    Join Date
    Feb 2012
    Location
    Boston USA, Wokingham UK
    Posts
    1,268
    Change

    Use t2

    To

    Select t2

  10. #10
    Member
    Join Date
    Apr 2013
    Posts
    88
    Thanks!

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us