Selecting a Single Record
This example executes a SQL command to return a specific customer and display it in a default jig.
The Jigx function in the example below is listed twice, once for executing a stored procedure and once for executing a query.
Link to full solution jig project on GitHub
The functions used to return a single record use forRowsWithMatchingIds: true. Only records in the SQLite table with a matching id will be updated. When forRowsWithMatchingIds is false or omitted, all records in the SQLite table will be deleted, and only the records returned by the stored procedure, or query statement will be inserted.
The listCustomers.jigx file must be modified to include an onPress action. When pressing on a list item in the customer list, Jigx will navigate to the viewCustomer jig. customerId is specified as a parameter that should be passed to the viewCustomer jig, where it is used in the where clause of the SQLite query to load the selected customer.
Add the following code to the bottom of the listCustomers.jigx file:
The complete code of the modified listCustomers.jigx should look like this:
The where clause in the query contains a token for a parameter called customerId that is defined in queryParameters and is passed to the viewCustomer jig as an input from the listCustomer jig.
The isDocument property for the mydata datasource is set to true. As a result, the data source will return as a single record to be displayed on a form instead of an array of records.
The data on the jig is displayed using an entity control and entity fields. If the data source returns an array, an entity control will automatically show the first record.
The YAML for viewing the selected customer is: