NetTalk Central

Author Topic: Reset a browse in a form clears the selected record and current search filter  (Read 5732 times)

Matthew51

  • Full Member
  • ***
  • Posts: 152
    • View Profile
    • Email
I have many forms in my app that contain 2 browses.  The first is a list of records that have been added, and the second is a list of records that can be added.

For example I have an invoice form where the first browse is a list of all items that are on the invoice, and the second is a list of every item that is for sale.  The second browse has a button the will add an item to the first browse.  See the example pic.

Both browses are added using the Procedure form element rather then having one be a child of the other.  And both have the other in their "Reset Other Fields" list.

The problem I'm having is that any action to one form will reset the selected field of the other to the first record.

I would like to
1.  Save the selected records so that the opposite form isn't always bouncing back to the top.
2.  Be able to set the selected record in the first form to the newly added record when the user click the add button on the second form.

Thank you
Matthew

Edit: Net Talk Version: 8.68
« Last Edit: April 18, 2016, 03:49:38 PM by Matthew51 »
Contractor with 10+ years of NetTalk experience looking for work.
www.linkedin.com/in/matthew-leavitt
BisWare.ca
Check out my free EasyTime Template

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Hi Matthew,

what backend are you using? TPS or SQL?

cheers
Bruce

Matthew51

  • Full Member
  • ***
  • Posts: 152
    • View Profile
    • Email
SQL

Edit: the primary keys are SQL identity fields.
« Last Edit: April 19, 2016, 10:26:36 AM by Matthew51 »
Contractor with 10+ years of NetTalk experience looking for work.
www.linkedin.com/in/matthew-leavitt
BisWare.ca
Check out my free EasyTime Template

Matthew51

  • Full Member
  • ***
  • Posts: 152
    • View Profile
    • Email
I think this may have gotten lost, so I'm going to give it a bump as my customers are bugging me about it. ;)

Thanks

Mathew
Contractor with 10+ years of NetTalk experience looking for work.
www.linkedin.com/in/matthew-leavitt
BisWare.ca
Check out my free EasyTime Template

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Hi Matthew,

Dealing with "position" in SQL gets a bit complicated because of the way SQL and the drivers work.
Your setup is very specific so I think a very specific example is in order.

Take the existing msSql example (example 73) and add a couple tables to the dict and some procedures to the app so you can show the effect you are seeing. Then post that here so I can hopefully duplicate the effect and possible find a solution.

cheers
bruce

Matthew51

  • Full Member
  • ***
  • Posts: 152
    • View Profile
    • Email
I didn't need to change the dictionary.  All my changes are visible when updating/inserting an invoice.  I've changed the page size of the Line Item browse to 5 to make testing easier.  To the right if the Line Items I've added a browse of products.  Clicking the add button will add the product to the line items.

If you are still on the first page of line items then it remembers what item you have selected after you click the add button.  If you are on any other page then the browse is set back to the first page and the first item is selected.

What I would like to happen is the newly added item is selected in the line items browse, so the user can easily change the quantity or price.  Or at the very least have the new item visible so they don't have to hit the last button, or go searching to the item if the browse isn't sorted by entry order.
Contractor with 10+ years of NetTalk experience looking for work.
www.linkedin.com/in/matthew-leavitt
BisWare.ca
Check out my free EasyTime Template

Matthew51

  • Full Member
  • ***
  • Posts: 152
    • View Profile
    • Email
I finally had some time to look at this again.  And I have a solution that's 80% their. In the embed point for the add button I have the following code :
Code: [Select]
Access:OrderDetail.Insert()
SQLFile{PROP:SQL} = 'SELECT MAX(OrderDetailID) FROM Ordering.OrderDetail WHERE OrderID = ' & p_web.gsv('Ohr:OrderID')
Next(SQLFile)
Access:OrderDetail.Fetch(Odt:PK_OrderDetail, SQL:F1)
p_web.SetValue('Odt:OrderDetailID', SQL:F1)
p_web.SetSessionValue(name(OrderDetail) & '_FormValue','K' & Position(Odt:PK_OrderDetail))

It finds the record that was just added, and set a session value the same as when a form was saved.  This is form my code, not the example I posted, but the idea should be similar.
At the end of the AjaxChildren Routine in the same procedure I added:
Code: [Select]
    p_web.SetValue('_refresh_','saved')I think this tricks the browse of included items that a new record was saved using a from.

I still have 2 problems

1: The sort order and search are still being reset to default
2: The browse with the add button is still getting reset to the first page.  I've tried adding variations of  "p_web.SetValue('_refresh_','saved')" to the same embed point on the included items browse, but none seem to work.  It could be because this browse has the selecting of items disabled.

I would like to be able to get these last 2 resolved so I can push it out with the next update

Thanks

Matthew



Contractor with 10+ years of NetTalk experience looking for work.
www.linkedin.com/in/matthew-leavitt
BisWare.ca
Check out my free EasyTime Template