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

Thread: Populating and refreshing Lianja sections

  1. #1
    Senior Member
    Join Date
    Jul 2013
    Location
    Ontario, Canada
    Posts
    658

    Populating and refreshing Lianja sections

    Hello,

    In my app, I call a server side procedure (.prg file) and return the results in JSON format.
    In the .js file, I can parse the JSON string to obtain the values.

    I would like to update a canvas label with one of the parsed values.

    Code:
    Lianja.get("page1.section1.lblName").caption = alltrim(parseddata.name);
    In the same situation, I would like to change the section header.

    How do I refresh the section or the label in the web view/browser to reflect the changed value?

    Cory

  2. #2
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    6,225
    As explained previously.

    The ID (name) of the UI object in a JavaScript canvas section is a javascript object. So if you have a label called m_label you can set the text using:

    Code:
    m_label.text = "Hello world";
    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
    Jul 2013
    Location
    Ontario, Canada
    Posts
    658
    Thank you Barry.

    I'm now so used to writing out all of the object association.

    How would I update a section header's caption?
    The same logic doesn't seem to work.

    Cory

  4. #4
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    6,225
    I don't think you can in the Web Client. Submit an ER.
    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
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    6,225
    Have you tried placing macros {....} in the section header and refreshing the section?

    You could have any expression in the macros including a javascript variable.
    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
    Senior Member
    Join Date
    Jul 2013
    Location
    Ontario, Canada
    Posts
    658
    Hi Barry,

    I like your suggestion although my attempts have failed.

    I'm most likely approaching this wrong, although here it how I'm thinking this is to be handled (by using a variable).

    In the section header caption, I add something similar to {m.headercaption}.
    In the main .js file, I add a declaration before all code similar to var headercaption = '';
    When I want to update the caption, I would set the value headercaption = "some text" and refresh the section.

    I've tried a few ways although none were successful.

    Could you provide more details how I should handle the macros?

    Thanks,
    Cory

  7. #7
    Lianja Team davefoss's Avatar
    Join Date
    Feb 2012
    Posts
    111
    Hi Cory,

    "m.varname" is a VFP convention, not JavaScript. Try removing the "m.".

  8. #8
    Senior Member
    Join Date
    Jul 2013
    Location
    Ontario, Canada
    Posts
    658
    Hi Dave,

    I have removed the "m.".
    Still no luck.

    When the app is loaded in the app builder, the console reports "Variable/field 'HEADERCAPTION' not found".
    The web app view and the browser preview do not display any errors.
    The header remains as {headercaption} regardless of how the page is being viewed.

    In the .js file before any code, the following is used:
    Code:
    var headercaption = " ";
    Cory

  9. #9
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    6,225
    remove var.

    window.headercaption = "hello world";
    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
    Jul 2013
    Location
    Ontario, Canada
    Posts
    658
    Hi Barry,

    I have removed the var keyword although I still can't get it too work.
    When the app is loaded in the app builder, the console still displays the same message.

    When I open the web app view, no change. Opening the debug window, setting window.headercaption and then refreshing the section works that way but it doesn't through code.
    When I preview in the browser, the header does not change either from code or the browser console window.

    Cory

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