Updating Dynamic Data
The employee's details are updated using the Dynamic Data provider's update method in this example. The same employee list (Reading Dynamic Data) is used to select the employee and then populate the employee form (Creating Dynamic Data) with the employee's existing details. Edit the required details and update the record in the Dynamic Data table.
Datasources, jigs, components & actions
default.jigx is the database where the Dynamic Data table is defined.
sqlite datasource calls the Dynamic Data provider, using an SQL query to return the data.
form is the component used with
initialValueproperties to populate the employee data into the form fields.submit-form is the action that executes the update method of the Dynamic Dataprovider with the
recordIdproperty configured to identify the record in the table that must be updated
Examples and code snippets

Use the employee list with component.expanders add the onContentPress action that will open the employee form, add parameters to transfer the employee details to the form.
title: Employee list
type: jig.list
icon: upload-bottom
header:
type: component.jig-header
options:
height: medium
children:
type: component.image
options:
source:
uri: https://images.unsplash.com/photo-1531545514256-b1400bc00f31?q=80&w=1374&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D
onFocus:
type: action.action-list
options:
isSequential: true
actions:
- type: action.sync-entities
options:
provider: DATA_PROVIDER_DYNAMIC
entities:
- default/employee
datasources:
my-employees:
type: datasource.sqlite
options:
provider: DATA_PROVIDER_DYNAMIC
entities:
- default/employee
query: SELECT
id,
'$.first_name',
'$.last_name',
'$.job_title',
'$.email',
'$.start_date',
'$.department',
'$.contact',
'$.address'
FROM
[default/employee]
data: [email protected]
item:
type: component.expander
options:
header:
centerElement:
type: component.titles
options:
title: =(@ctx.current.item.first_name & ' ' & @ctx.current.item.last_name)
subtitle: [email protected]_title
icon: person
children:
- type: component.entity
options:
children:
- type: component.entity-field
options:
label: Position
value: [email protected]_title
- type: component.entity-field
options:
label: Department
value: [email protected]
- type: component.entity-field
options:
label: Contact
value: [email protected]
contentType: phone
- type: component.entity-field
options:
label: Email
value: [email protected]
contentType: email
# When the list item is expanded and you press on the details you are directed to the form that is populated with the employee's details
onContentPress:
type: action.go-to
options:
# Specifiy the jig to go to
linkTo: update-employees
# Set a inputs for the current selected item so that the data record will populate in the form's initialValue field
inputs:
employee-detail: [email protected]tables:
employee: nullname: employees
title: Employees
category: business
tabs:
home:
jigId: list-employees
icon: home-apps-logo In the pre-populate Update Employee form add the action.submit-form using the Dynamic Data provider with the update method to update the data record.
title: Update Employee
type: jig.default
header:
type: component.jig-header
options:
height: medium
children:
type: component.image
options:
source:
uri: https://images.unsplash.com/photo-1522202176988-66273c2fd55f?q=80&w=1471&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D
children:
- type: component.section
options:
title: Personal Information
children:
- type: component.form
# Give the form an ID
instanceId: update-form
options:
children:
- type: component.text-field
instanceId: id
options:
label: id
# populate the field using the input parameter set in the list jig for the selected employee
initialValue: [email protected]
isHidden: true
- type: component.text-field
instanceId: first_name
options:
label: First Name
# populate the field using the input parameter set in the list jig for the selected employee
initialValue: [email protected]_name
- type: component.text-field
instanceId: last_name
options:
label: Last Name
# populate the field using the input parameter set in the list jig for the selected employee
initialValue: [email protected]_name
- type: component.text-field
instanceId: address
options:
label: Address
# populate the field using the input parameter set in the list jig for the selected employee
initialValue: [email protected]
- type: component.text-field
instanceId: contact
options:
label: Contact Information
# populate the field using the input parameter set in the list jig for the selected employee
initialValue: [email protected]
- type: component.text-field
instanceId: email
options:
label: Email
# populate the field using the input parameter set in the list jig for the selected employee
initialValue: [email protected]
- type: component.section
options:
title: Employment Information
children:
- type: component.text-field
instanceId: job_title
options:
label: Job Title
# populate the field using the input parameter set in the list jig for the selected employee
initialValue: [email protected]_title
- type: component.text-field
instanceId: department
options:
label: Department
# populate the field using the input parameter set in the list jig for the selected employee
initialValue: [email protected]
actions:
- children:
- type: action.submit-form
options:
# The formId is used to get the context to the fields and values that need updating in the form
formId: update-form
# The Dynamic Data provider uses the update method to update the record in the employee table
provider: DATA_PROVIDER_DYNAMIC
title: Update Record
entity: default/employee
method: update
# The specify the record that must be updated in the Dynamic Data table by referencing the current data stata of the components in the form
recordId: [email protected]
onSuccess:
type: action.go-backname: employees
title: Employees
category: business
tabs:
home:
jigId: list-employees
icon: home-apps-logo
update:
jigId: update-employee-form
icon: upload-button-alternate Navigate to the solution's Data option in Jigx Management and view the updated Dynamic Data employee table and record.

Last updated
Was this helpful?