From wiki.ginstr.com
Jump to: navigation, search

gn:act_update_values

gn:act_update_values has all the properties of gn:act_update with one difference. When a certain column in updating row data is omitted, the previously saved column value for this omitted column is kept. This action can easily append or update certain columns only, leaving the rest of the row as it was.

It's important to keep in mind when updating a record to perform clean data of dbRequest that will be updated in order to remove existing "leftover" data from dbRequest.

gn:act_update_values updates existing record in database with values from dbRequest. Update action has integrated gn:act_getWidgetData action which is executed before the update to database.

The procedure to update a record would be:

  1. Load single row from database
  2. Edit the data
  3. Update row

In case there are multiple rows loaded from database i.e. for dropdown, it’s necessary to link the update action with correct row selected in dropdown. In this case it’s necessary to use a different action signature.

More information on this topic is provided here.

Can be used on widgets
any widget
Event trigger for action
click on the widget that contains this action in attributes, or in the action set, conditional action.
Can be used as

Additional required attributes on bound widget

gn:data_request=”dbRequestName”

Additional required attributes on other widgets:

For widgets whose data will be extracted:

  • gn:data_request=”dbRequestName” – must be identical to the name of the request in bound widget
  • gn:data_field=”fieldName” – must be identical to field in queries.xml for this dbRequest

Action signature

gn:act_update_values=[]
updates data from entire dbRequest
gn:act_update_values=[@+id/widgetId,…,@+id/widgetId]
updates data from widgets that are set as target for dbRequest
gn:act_update_values=[@+id/widgetDbRequestSelector;@+id/widgetId,…,@+id/widgetId]

Value field content

If no value is provided, data is retrieved from all widgets on screen and saved into the persistent storage and to the database.

If widget id’s are provided, data is retrieved only from those widgets and saved into the persistent storage and to the database.

widgetDbRequestSelector
if multiple rows are returned from database for dbRequest before updating a row, target widget will have to be defined which will identify the “selected” row and update data to it
Note: at present this is only implemented for GnDropDown. The display data in dropdown has to be unique. i.e. we load 10 objects from database and select one in dropdown. When we execute update action, gn:act_update will know which row of the 10 to update based on the selection in dropdown.