Page 1 of 3 123 LastLast
Results 1 to 10 of 23

Thread: Changing GUI records programatically in web

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

    Changing GUI records programatically in web

    Hi Barry

    We are trying to change records programatically in web so we can stay on a newly inserted record when user presses save. Currently the GUI display record jumps to the last record in the index - Mr Yoyo.

    By the time the user presses Save we have a unique customer ID and probably a record number.

    What is the best way of jumping back to the newly inserted record in an index ordered table?

    We assumed we would make a field into a section search field and use Lianja.showDocument("section:section1?action=searc h&text=" + lcust_id);

    It works in dev from Lianja console but cannot make it work in web. Also cannot find the right place to call it from. Afterinsert section delegate seems too early as it is called on insert and we don't yet have our unique ID ( guid() ). We want it when the user presses save, just before the record jumps to the last record in the index - Mr Yoyo.


    Our records are displayed in customer name order but we have a section search field set to cust_id which is a guid(). We currently only have two indexes on the table ie lower(name) and lower(cust_id) as guid() seems to be stored as lower case.

    So any advice as to the best way to search for the cust_id field using js and then move the current record pointer?

    Thanks in advance



    Simon

  2. #2
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,164
    Blog Entries
    22
    Simon,

    you do not need to use upper() and lower() on indexes in Lianja.

    yes, if you view records ordered by a certain column the records will be navigated in that order.

    if you then add a new record the record displayed will be the record in the ordinal position in the ordered list of records.

    using guids results in random key values that have no meaningful order for the records displayed.
    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
    Jan 2014
    Posts
    369
    Hi Barry

    Think we are talking slightly at cross purposes.

    Lianja added the lower(keyvalue) when it was a search field so we thought that was the sensible thing to do.

    We want to keep the display in alphabetical name order but thought to use the guid() purely to find a particular record as it is unique.

    Ok so how do we go about maintaining the display on a newly added record?

    *************************************

    For example


    Some existing record displayed (in alpha name order)
    add new record - Smith
    Press save
    Smith still displayed

    That is all we are trying to do. How do we achieve that?

    Thanks in advance


    Simon

  4. #4
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,164
    Blog Entries
    22
    Hi Simon

    What is the order for the section.
    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
    Jan 2014
    Posts
    369
    Hi Barry

    Order = name

    Cheers

    Simon

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

    Have you specified a searchkey field on that section? you can just check the name field as a search key field, you don't need to "order by" also.

    You can turn on odata tracing in the server manager and look at the odata_trace files in the debug directory.
    Last edited by barrymavin; 2022-05-18 at 05:02.
    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
    Senior Member
    Join Date
    Jan 2014
    Posts
    369
    Hi Barry

    Ok - done a lot of testing in web and understand what is going on rather better. We hope this will allow us to ask a better question.

    Our app is 1 page with 8 sections (1 form, 1 image, 6 canvas)

    If we remove the "order by" setting on all sections we get an unordered table displayed in browser - which makes sense. The only way to get a table ordered by "name" is to have the "order by" = name in every section. Putting a search field in the first section doesn't seem to make any difference.

    When we look at the odata_tracexxxx.txt files we find the following pattern :

    Load up app and display 1st record

    5 different odata_tracexxxx.txt files, each containing 8 separate odata_read() entries (1 for each section makes sense but not sure why there would be 5 different files. Difficult to tell if they are all separate discreet reads as the timestamps are the same in many of the odata_read() )

    In all of these odata_read(), the SQL for each read is "select * from cust order by name limit 1 " which makes sense as it is displaying the 1st record ordered by name.


    Add a record

    24 records in the table before we add another one.

    We can see

    odata_build_insert_statement() dbtype=lianja jsondata={"ntitle":"","salut":"New","name":"Record 004","telmobile":"","telhome":"","telwork":"","ema il":"","adl1":"","adl2":"","adl3":"","adl4":"","ad l5":"","postcode":"","cust_id":"8D7EE8E6-F7C5-4356-A44E-D7E9EF4BA7B3","timestamp":"2022-05-18 13:01:26","company_no":"31","companyname":"ABC Test Dealer","wants":"","make":"","model":"","colour":" ","exported":0} updatefieldlist=
    **** odate_read **** uri=pdsw/cust?$top=1&$skip=23&$rowid&$orderby=name&_v=48&_=1652874935194

    Record added

    Now display a record after add

    select * from cust order by name limit 23,1


    This select statement looks like the cause - it is displaying the last record by default. That makes sense in an unordered table as the recently added record would also be the last record, so if it needs to be like that by design - fair enough.

    So now how do we move the display to the just added record bearing in mind that the just added record (ordered by name) could be anywhere?

    This is why we thought the use of a unique field might help but if there is a neater way of accomplishing the same thing, that would be far preferable. What can we get hold of to re-display the record?

    Hope that helps to encapsulate the question more succinctly.

    Thanks in advance


    Simon
    Last edited by SpringBox; 2022-05-18 at 08:22.

  8. #8
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,164
    Blog Entries
    22
    Hi Simon

    i will investigate this.
    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

  9. #9
    Senior Member
    Join Date
    Jan 2014
    Posts
    369
    Thanks Barry

  10. #10
    Senior Member
    Join Date
    Jan 2014
    Posts
    369
    Thanks Barry

    Can't think of a scenario where the just added record shouldn't be displayed after the add.

    Cheers


    Simon

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