Results 1 to 6 of 6

Thread: Grid section descending sort

  1. #1
    Senior Member
    Join Date
    Jan 2014
    Posts
    351

    Grid section descending sort

    Hi All

    I have a page with a form section and a child grid section. Using the Southwind database, I would have customer in the form and Orders in the grid. I wish to display the grid records in descending order of the order date so that the most recent order shows on top by default.

    The grid's "OrderBy" attribute is only for the top most section and not for child sections and it has to be ascending order. May I know what is best way to sort the child order grid by descending order of the order date?

    Your advice is most appreciated

    Thanks & Best Regards

  2. #2
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    5,769
    A relationship between two sections in determined by the parent and child key expressions. You are essentially joining two data sources.

    If you have a need to do something above and beyond the standard behavior you will need to use custom code.
    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

  3. #3
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    1,942
    Hi TH,

    It can be done in desktop, but not in Web (I will submit a ticket), using the old-fashioned VFP way of doing this.

    The example is from the order_details section of example_webapp1.

    In the Related Data section of the Section Attributes dialog enter the following:

    Parent Key: str(orderid,10)
    Child Key: orderdown

    Now, create an index on order_details;

    create index orderdown on order_details (str(orderid,10),str(quantity,20) desc)

    That's all it takes.

    Now, all quantities related to an order will be shown with quantities in descending order.

    enjoy,

    Hank

  4. #4
    Senior Member
    Join Date
    Jan 2014
    Posts
    351
    HI Hank

    Thanks for sharing. BTW, if my app uses MSSQL and my Lianja app uses VT to access MSSQL, can I still use the index tag approach to sort my grid?

    Once again, your advice most appreciated

    Thanks & Best Regards

  5. #5
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    5,769
    That is not how section relationships operate.

    The child key is a column not an index tag.

    When a record is added to a child section the parent key expression is evaluated and the child key column is populated with that value.

    If you want non standard parent / child relationships you need to custom code it.

    And to answer your question about using Lianja indexes with VTs, no that will not work at all in web apps.

    You can maybe fudge it but it will be error prone.

    Best solution would be to create a VT which has an ORDER BY clause on the SQL SELECT statement and bind that to your child section.
    Last edited by barrymavin; 2020-02-09 at 03:27.
    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

  6. #6
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    1,942
    Hi TH,

    As Barry explained, the "key" approach won't work in related data. My reply was with regard to Lianja data, using a table, not a VT.

    For VT's, Barry has described what to do.

    Hank
    Last edited by HankFay; 2020-02-09 at 19:54.

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