Search/Display multiple Records using Datasource
Tip: You can use Manage Records to list the database’s Records without running the application.
To display a list of Records from the database in your application, you will need to add a Search/Display multiple Records Datasource. This Datasource is required in order to specify when to load the records and how to display them.
- Navigate to the Screen that you want to add the Datasource.
- Press the Datasource button, and then the + Create datasource button.
- Select the Kodika Server tab.
- Select the Data Type that you want to fetch records from.
- Select Search/Display Multiple
Data Type Name
. - Select the Records to fetch.
- Fill in the Advanced Search parameter, if needed.
- Change the Sorting, if needed.
- Set a Limit to the results that will be displayed, if needed.
- Connect at least the parameters of the On Success response.
- Press Save.
- Close Datasource popup.
- Create a Start a Datasource Request Event Action and connect it to an Event, if needed.
Select the Records to fetch
There are two ways to display a List of Records.
- Get all Records from the database and use Advanced Search, if needed, to filter them.
- Get the Records referenced from a Relationship and define the parent Record.
Examples for Get All
- Show all the Posts. You can use Advanced Search to filter only the ones posted in the last 30 days.
- Show all the Categories of the application.
Examples for Relationship Reference
- Show the Posts of a specific Category. You have a Category Data Type with an One to Many Relationship to the Post Data Type. You select to display the Category -> Posts and bind the Category to the Category with the Posts.
- Show the Friends of the Author of a Post. You have a Post Data Type with an One to One Relationship to the User Data Type that is the author of the Post. User Data Type has a Many to Many Relationship to the User Data Type that is the Friends of the User. So, by selecting the Post -> Author -> Friends option and then binding the Post, you can have the Friends of the Author of the Post.
Request Parameters
Filter
Change the records that will be fetched.
Advanced Search
Combine AND and OR conditions on the Records that have been already filtered.
Sorting
Select the Data Type property and the order (Ascending/Descending) that the Records will use to get sorted.
Limit
Type the number of Records you want the datasource to display. The Limit will be applied after the Advanced Search and Sorting. Note: Leave the value empty to display all the fetched records.
Responses
Note: If any of the validations failed, the On Success response is not called, and only the respective failure response is called.
On Success
Called when the records are fetched successfully.
Parameters:
- records: The List of the records that were requested.
When Wrong Filter Value
Called when the the root record to fetch from does not exist.
Parameters:
- Error: A text with an error message.
When Offline
Called when the user has no Internet connection.
Parameters:
- Error: A text with an error message.