Page 1 of 4 123 ... LastLast
Results 1 to 10 of 32

Thread: Get record data from treegrid

  1. #1
    Senior Member
    Join Date
    Apr 2012
    Location
    United Kingdom
    Posts
    657

    Get record data from treegrid

    I have a page with two canvas sections on it.

    1st section is egg data
    2nd section is weights for the egg

    On 2nd section I have a treegrid control which is populate by the sql statement:

    select tweight,nweight,nperlossatpip,lnotes,calive,ldrill ed,nveingrowth,cpk_deggweight from deggweight where deggweight.cfk_degg = "{degg.cpk_degg}"

    When I move through rows on the treegrid I need the the egg weight page to show the data for that entry.

    The sql statement contains the PK for the weight entry so I assume I need to get that and set it somewhere so that the egg weight section refreshes to show the weight entry.

    Just can't figure out how to get the PK from the Treegrid control and where to set it to get the record in the weight section to got that record.

    I've looked at the examples, but most are done with nocode and I can't figure out how to do this.

  2. #2
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    6,970
    Blog Entries
    18
    A picture says a thousand words. Use the click delegate. See code below.

    Click image for larger version. 

Name:	Screen Shot 2022-03-23 at 5.55.49 PM.jpg 
Views:	137 
Size:	106.2 KB 
ID:	2786
    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
    Senior Member
    Join Date
    Apr 2012
    Location
    United Kingdom
    Posts
    657
    Hi Barry

    I've put this in the click of the treegrid

    ////////////////////////////////////////////////////////////////
    // Event delegate for 'click' event
    proc page1_EggWeight_EggWeightGrid_click()
    Lianja.writeOutput("Clicked on row ") + etos(this.activerow) + ", info = "etos(this.item(this.activerow,2)))
    endproc


    I just get "Clicked on row" printed in the console

  4. #4
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    6,970
    Blog Entries
    18
    Lianja.writeOutput("Clicked on row " + etos(this.activerow) + ", info = " + etos(this.item(this.activerow,2)))
    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

  5. #5
    Senior Member
    Join Date
    Apr 2012
    Location
    United Kingdom
    Posts
    657
    Hi Barry,

    Thank you, it was my trying to read it off an image

    That works.

    I set it for each column and get

    Clicked on row 1, info 1 = / / : : AM
    Clicked on row 1, info 2 = 65.23
    Clicked on row 1, info 3 = 4.49
    Clicked on row 1, info 4 = True
    Clicked on row 1, info 5 = Unknown
    Clicked on row 1, info = 6 False
    Clicked on row 1, info = 7 0
    Clicked on row 1, info = 8

    Date is empty in the Treegrid and in the output to console, but in the table there is a datetime record

    In the sql statement for the tregrid I have the pK of the deggweight record as the last column.

    That is empty in the output as there are only 7 items in the List Items for columns

    If I add another one to the list the output gives the PK value.

    However I obviously do not want to show this in the TreeGrid, so how does one do that, other than perhaps having it there and making the grid width such that it does not show it, which seems and bit of a shame.

    ( edit note - sorted that by setting it's width to 0 )

    Once I have the value where do I use it to move the display on the egg weight page to that record
    Last edited by avianmanagement; 2022-03-23 at 08:05.

  6. #6
    Senior Member
    Join Date
    Apr 2012
    Location
    United Kingdom
    Posts
    657
    I have tried this but if does not refresh the section

    ////////////////////////////////////////////////////////////////
    // Event delegate for 'click' event
    proc page1_EggWeight_EggWeightGrid_click()

    local lcEggWeightPK
    lcEggWeightPK = (this.item(this.activerow,8))
    Lianja.getElementByID("page1.EggWeight").childKeyE xpr = lcEggWeightPK
    Lianja.getElementByID("page1.EggWeight").refresh()

    //Lianja.writeOutput("Clicked on row " + etos(this.activerow) + ", info = 8 " + etos(this.item(this.activerow,8)))
    endproc

    lcEggWeightPK has a value if I put a set step on before it

    If I write it to the console I get different values for each row I click on
    Last edited by avianmanagement; 2022-03-23 at 11:03.

  7. #7
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    6,970
    Blog Entries
    18
    Hi David

    Lianja.getElementByID("page1.EggWeight").childKeyExpr = lcEggWeightPK

    That makes no sense. No idea why you are messing about with the childkeyexpr.

    Let’s take a step back, What exactly us it you are trying to do and want to achieve.
    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
    Senior Member
    Join Date
    Apr 2012
    Location
    United Kingdom
    Posts
    657
    Hi Barry,

    Yes I see that now !

    What I am trying to do is this:

    Canvas section with tree grid.

    It has say 4 rows and I'm currently on row the last row.

    I want to use the mouse and click on row 2 lets say and have the section's data show that, then click on row 4 and it goto that one.

    Name:  treegrid.png
Views: 51
Size:  38.7 KB

  9. #9
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    6,970
    Blog Entries
    18
    But the grid is in that canvas section David.

    So you want to update the whole section? or just UI elements that are bound to the same table as the grid?
    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

  10. #10
    Senior Member
    Join Date
    Apr 2012
    Location
    United Kingdom
    Posts
    657
    Hi Barry,

    Yes the Treegrid is in the canvas

    The Treegrid is populated from a select statement off the same table as the section is populated from, dEggweight

    One of the fields in the select statement for the Treegrid is the PK, This does not show in the tree grid, but is column 8.

    select tweight, nweight, NPERLOSSATPIP,lnotes,calive,ldrilled,nveingrowth,c pk_deggweight from deggweight where deggweight.cfk_degg = "{degg.cpk_degg}"

    Use clicks on row 2 and whole section moves to that record and refreshes the UI.

    So yes I want to update the whole section.


    David

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