How to Insert, update, view in form using same foundset.

Find out how to get things done with Servoy. Post how YOU get things done with Servoy

How to Insert, update, view in form using same foundset.

Postby hardina09 » Mon Sep 17, 2012 10:21 pm

In my form I need to insert, update and view data in one form itself based on same foundset. (I am not using any relations)

To add a new record and update record I am using same set of text field
I am using table view to view data and selects record to edit. The selected records gets populates in record view text fields.
Both record view and table view are in same form within tabless panal

1. How can I refresh foundset for newly added record in foundset and show new record added at the end of table
2. The problem table view is latest values get displayed in tableview but selecting record does not populates in record view
3. For updating values, I facing problem that moment values in record view gets changed is reflected in table view that means value in any text field is change at same moment it gets changed in table view. I don't want that after updating value, user need perform some action (hit save or update button).

plz suggestion...
hardina09
 
Posts: 62
Joined: Tue Apr 24, 2012 9:46 pm

Re: How to Insert, update, view in form using same foundset.

Postby ngervasi » Tue Sep 18, 2012 12:58 pm

So basically you have a table view form and a detail record view form, all you need to do is make sure that both of them are using the same foundset. If so when you add a record in the detail view the record is added to the table view as well and all changes are kept in sync automagically.
Maybe a screenshot would help understanding your scenario.
Nicola Gervasi
sintpro.com
SAN Partner
ngervasi
 
Posts: 1485
Joined: Tue Dec 21, 2004 12:47 pm
Location: Arezzo, Italy

Re: How to Insert, update, view in form using same foundset.

Postby hardina09 » Tue Sep 18, 2012 2:16 pm

Thanks ngervasi.
You are correct both detail view and record view is sharing same foundset.Adding a new record is fine. it is working properly. But the problem is any update made in detail view immediately reflects in table view. I don't want to do that. once update is done in detail, user needs to click UPDATE button and changes made should be shown in table view. Secondly, Is there any way where I can update or refresh database through javascript, is it necessary to use databaseManager.refreshRecordFromDatabase(foundset,index) or not.
hardina09
 
Posts: 62
Joined: Tue Apr 24, 2012 9:46 pm

Re: How to Insert, update, view in form using same foundset.

Postby ngervasi » Tue Sep 18, 2012 3:16 pm

That's how databroadcast works: if the same record is shown in different forms you always see changes instantly.
You have 2 option:
1) Keep it the way it is and revert back to the original values if the user clicks the Cancel button
2) Don't work directly on the original record in the detail view; you can simply design your detail form with one form variable per record column and apply the chages to the record only if the user clicks the Save button.

databaseManager.refreshRecordFromDatabase() is only needed if the db data has been altered OUTSIDE servoy (from a website, from a SQL tool, etc), all changes made by servoy clients (smart, web and headless) are broadcasted instantly to all other clients.
Nicola Gervasi
sintpro.com
SAN Partner
ngervasi
 
Posts: 1485
Joined: Tue Dec 21, 2004 12:47 pm
Location: Arezzo, Italy

Re: How to Insert, update, view in form using same foundset.

Postby hardina09 » Tue Sep 18, 2012 4:42 pm

Awesome. Your explanation is good. I worked with option #2, works as per requirement.

Thanks ngervasi
hardina09
 
Posts: 62
Joined: Tue Apr 24, 2012 9:46 pm


Return to How To

Who is online

Users browsing this forum: No registered users and 6 guests

cron