Results 1 to 7 of 7

Thread: Data mapping in grid and command buttons in canvas

  1. #1

    Data mapping in grid and command buttons in canvas

    Hi! I'm just starting with Lianja and I have to say that I'm having a very good experience. It seems very powerful and flexible to me. On the other hand I'm having a lot of difficulties finding training resources and documentation (I think that it's normal having in mind that it is an almost "new" environment). If someone issues a training course or a book will have here a client!
    On the other hand I'm trying to figure out how to advance and emulate the programs that I normally do with other tools. I have two doubts that I haven't been able to solve with the forum:
    -On a canvas section I'm trying to insert some custom buttons mainly for navigation and basic actions. I've tried several ways but with no luck. On exemple, for a "move to next record" button in a desktop app what I'm doing is to create a new page(page1), a new canvas section (section1), drop in some record fields, and then I insert a command button, typing in the Default action field of the control: section:section1?action=next. When I click it, it seems that nothing happens, or almost the fields are not refreshing. How can I use the "default actions" in a button in the canvas section?
    -My second doubt I think is related with data mapping, but I'm not sure. Using the southwind database and trying to do a simple invoicing program, I create a new page (page2), add a form section (section1) and drop there the orders table fields. I then add a second section, but this time is a grid(section2) and I add the order details fields (order id, product, price, qty). Then, I try that the price field automatically updates its content with the "unit price" that figures for that product in the products table, whenever you change the product. If you select product 1, in the price field of the grid should automatically appear the "unit price" of the product 1 that is in the products table. I thought that I could get that with data mapping but I'm a little bit lost, as I also want the user to be able to overwrite that value. I've tried to specify in the "get data mapping" field of the price column: keylookup("products","productid",{},unitprice), and leaving set data mapping blank, but it doesn't work.
    Any idea on these issues?
    Thank you!
    Carlos.

  2. #2
    Lianja Team yvonne.milne's Avatar
    Join Date
    Feb 2012
    Location
    Berkshire, UK
    Posts
    1,840
    Hi Carlos,

    1. There does appear to be a problem with the 'Default action' - we will look into that.
    If you put the code in the Click event delegate for your button that will work.

    JavaScript:

    Code:
    ////////////////////////////////////////////////////////////////
    // Event delegate for 'click' event
    function page1_section1_field1_click()
    {
    	showdocument("section:section1?action=next");
    };
    VFP (remember to use JavaScript if you want to run in the Lianja Web Client)

    Code:
    ////////////////////////////////////////////////////////////////
    // Event delegate for 'click' event
    proc page1_section1_field1_click()
    	showdocument("section:section1?action=next")
    endproc
    2. The keylookup() needs to reference the order_details.productid, not the current unitprice cell value, which is what the {} means in

    Code:
    keylookup("products","productid",{},unitprice)
    So it becomes:

    Code:
    keylookup("products","productid",order_details.productid,unitprice)
    The 'Recalculate' attribute on the productid column should be checked to True to trigger the recalculation of calculated and readonly columns in the Grid.

    Regards,

    Yvonne

  3. #3
    Hi Carlos,

    Let's take this one step at a time.
    It seems like you added a canvas section and then added some textfields, and some buttons.
    I am using the southwind database in my example.
    1. Drag the fields from the table you want onto the canvas from table itself.
    I have selected the 'example' table
    Name:  carlos1.jpg
Views: 525
Size:  81.9 KB

    2. Add your buttons.
    3. In the button that you want to use to move the records forward, add the following code. On my section, I named them txtNext and txtPrior (not case sensitive in VFP).

    Here is the code from click events.

    // Event delegate for 'click' event
    proc page1_section1_txtPrior_click()
    select example
    if not bof()
    skip -1
    Lianja.get("page1.section1").refresh
    else
    wait window " You are on the first record"
    endif
    endproc


    ////////////////////////////////////////////////////////////////
    // Event delegate for 'click' event
    proc page1_section1_txtNext_click()
    select example
    if not eof()
    skip 1
    Lianja.get("page1.section1").refresh
    else
    wait window " You are on the last record"
    endif
    endproc

    Herb

  4. #4
    One thing I keep saying about Lianja - there are a lot of ways to accomplish the same thing

    Herb

  5. #5
    Uou! Thank you both very much. I have to say that I'm not familiar with javascript or VFP, so at the moment I'm doing everything mainly on Python and secondly in PHP where I'm more proficient. Your directed my attention to two things:
    -If I want to not worry with web compability it is much better to develop everything in Javascript. Is this also applicable to the development for mobile devices?
    -Not everything works the same in the 4 languages. It seems that I'm unable to replicate the code for the buttons in Python, as I receive the error message: 'AttributeError: 'module' object has no attribute'showdocument'' when I use: 'Lianja.showdocument("section:section1?action=next ")'. Is it possible to use this in Python?
    Also, the code with the data mapping works fine, but the price is not updated until I click the refresh button in the grid. Is it possible to add an option to refresh the grid automatically in that delegate?
    Thank you!
    Carlos.

  6. #6
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,159
    Blog Entries
    22
    Python, PHP and JavaScript are case sensitive. Lianja/VFP is case insensitive, so Lianja.showDocument() is what you need to use.

    Web and Mobile use JavaScript on the client (delegates) but the client side code can call server side code written in Lianja/VFP or JavaScript. We will be adding PHP and Oython into the cloud server in a point release after v2.0 is released.
    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

  7. #7
    Fantastic Barry. Now it works. Thank you very much. These are very good news also.
    Carlos.

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