Results 1 to 9 of 9

Thread: Enabling Editable Fields in a Canvas Grid

  1. #1
    Member
    Join Date
    Oct 2012
    Posts
    32

    Enabling Editable Fields in a Canvas Grid

    Our VFP apps allow clients to tag deals listed in a grid to enable batch processing of those deals. Using the below page load() proc, the grid successfully populates but the grid is not modifiable even though the "editable" box is checked. This makes sense as the "SELECT" results are not attached to a table or cursor. (In VFP, we just allow the Chosen column to be modified as a checkbox -- haven't figured how to get the checkbox in Lianja yet.)

    proc page1_load()
    messagebox("Made it 1")
    m_deals = lianja.getelementbyID("gDealList") //get the Grid ID
    m_deals.addItems("select chosen,long_name,filename,settle_dt from deallist597") //populate the Grid
    endproc


    Name:  Test_Screen.JPG
Views: 179
Size:  54.3 KB
    So, I wanted to try populating the grid from a readwrite cursor to see if the would solve the problem using the following code:

    proc page1_load()
    messagebox("Made it 1")
    select chosen,long_name,filename,settle_dt from deallist597 into cursor deals597 readwrite
    m_deals = lianja.getelementbyID("gDealList")
    m_deals.addItems("select * from deals597")
    endproc


    However, this code produces the following error messages:

    Thu May 9 16:27:19 2013
    **** Lianja error ****
    DECLARE _DAO000C READ ONLY CURSOR FOR select * from deals597;

    ^
    METHOD 'ADDITEMS' not found
    Called from procedure - page1_load at line 13


    Naturally the grid display is now empty. Any suggestions?

  2. #2
    Member
    Join Date
    Oct 2012
    Posts
    32
    fwiw, if I remove the READONLY clause, the debug errors window still shows:

    Thu May 9 16:52:47 2013
    **** Lianja error ****
    DECLARE _DAO0012 READ ONLY CURSOR FOR select * from deals597;
    ^
    METHOD 'ADDITEMS' not found
    Called from procedure - page1_load at line 13


    Also, the SQl command:
    select chosen,long_name,filename,settle_dt from deallist597 into cursor deals597 readwrite

    works fine in VFP 9
    Last edited by Jeff_Stone; 2013-05-09 at 16:15. Reason: typo

  3. #3
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    1,949
    Quote Originally Posted by Jeff_Stone View Post
    fwiw, if I remove the READONLY clause, the debug errors window still shows:

    Thu May 9 16:52:47 2013
    **** Lianja error ****
    DECLARE _DAO0012 READ ONLY CURSOR FOR select * from deals597;
    ^
    METHOD 'ADDITEMS' not found
    Called from procedure - page1_load at line 13


    Also, the SQl command:
    select chosen,long_name,filename,settle_dt from deallist597 into cursor deals597 readwrite

    works fine in VFP 9
    Hi Jeff,

    every cursor in Lianja is readwrite; try leaving that off.

    Also, you can use that SELECT to populate the grid directly.

    For more control, you can create a virtual table, which allows you to set various properties, etc., and also to change backends as you wish, using a macro "{m.cMyConnStr}" for the connection string -- which I declare in the INIT of the app, and which I would program to load dynamically when deploying.

    hth,

    Hank

  4. #4
    Member
    Join Date
    Oct 2012
    Posts
    32
    Hank,

    Thanks for the reply. The error is the same even with "readwrite" removed. I have never worked with virtual tables. What did you mean "you can use that SELECT to populate the grid directly"? As mentioned above, when I used the following commands, the grid populated correctly but was not editable:
    m_deals = lianja.getelementbyID("gDealList") //get the Grid ID
    m_deals.addItems("select chosen,long_name,filename,settle_dt from deallist597") //populate the Grid


    Is there a different way of populating the grid with SELECT?

    I have never heard of or used VIRTUALTABLE before. I looked at the Lianja documentation on it but I'm confused as to how I would employ VIRTUALTABLE any differently than what I did with the SQL command that does populate the grid but was not editable. Would I create the virtualtable first and then SELECT from that?

    tia

    Jeff

  5. #5
    Senior Member
    Join Date
    Feb 2012
    Posts
    1,214
    Hi Jeff,

    I started out looking at it the same way you did. Virtualtables handle the connectstring to the SQL Server backend and greatly simplify updating your data.
    I'll look for an example that I use and post it a little later.

    Herb

  6. #6
    Lianja Team yvonne.milne's Avatar
    Join Date
    Feb 2012
    Location
    Berkshire, UK
    Posts
    1,380
    Hi Jeff,

    Have you thought of using a standard Grid Section? (I know you'd like to have a checkbox rather than a combobox for the logical field - we've got your ticket for that one). If you 'Hide header' on the Grid Section, you can have a Canvas above it with your other controls and the two will blend together (note: Header shows in Development mode and is hidden in Runtime mode). If the Grid Section itself is 'Readonly' = False, but all columns apart from your logical 'Chosen' field are set to 'Readonly' = True (double-click on the column header to set the attributes for individual grid colums), then only that column will be editable. Any columns from the table not required can be Removed (right-click on column header). The data in the Grid itself can be restricted using the grid.filter property. For example, in my screenshot I use the southwind!products table in the Grid Section called section1 and I could do this to only show Category 2 products:

    Code:
    oGrid = Lianja.get("section1").grid
    oGrid.filter = "categoryid = 2"
    Name:  grid.jpg
Views: 161
Size:  87.4 KB

    Note the Canvas Section TreeGrid does not have in-column editing, so you would need to change the Chosen field using scripting in, for example, the Click event.

  7. #7
    Member
    Join Date
    Oct 2012
    Posts
    32
    Hi Yvonne,

    We considered the approach you outlined previously. Our problem is our clients want on OptionGroup and some other fields placed to the side of the grid. Because Lianja default sections take up the entire width of a page, we couldn't figure any other way to meet there wishes than to use a canvas or customized section.

    Thanks,

    Jeff

  8. #8
    Lianja Team yvonne.milne's Avatar
    Join Date
    Feb 2012
    Location
    Berkshire, UK
    Posts
    1,380
    Hi Jeff,

    In that case, you might want to consider using a custom Navigation Panel - maybe not available when you first looked at the standard Grid Section. Your Navigation Panel could be based on a Custom UI Page with a Canvas and appear along side the Grid Section. The example_customnavpanel App in the distribution has an example Navigation Panel based on a Page with standard sections; my screenshot below shows a Page with a Canvas section. Just build the Page you want in a new App, giving it a unique Page name and use the 'Save in the Page Library' button to make it available to other Apps.

    Name:  navpanel.jpg
Views: 179
Size:  76.7 KB
    Name:  Page_Attributes.png
Views: 180
Size:  17.2 KB

    Yvonne

  9. #9
    Member
    Join Date
    Oct 2012
    Posts
    32
    Hi Yvonne,

    That may do the trick. I will play for a bit. Thanks very much for the suggestion.

    Regards,

    Jeff

    (Incidentally, I noticed that when a checkbox is used with the header above it, the checkbox itself is left aligned relative to the header. Esthetically, it might look nicer if it were centered underneath the header.)

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