How do I add data to my app? | Aquro Help Center
To add your data to your application you first need to know the basics of data in your app.
You need to know the concept of Data Models, Data Collections, and Data Items. Please read this information first and also read the introduction to app data.
After you read the above documentations you should now know the basics of working with data in your app.
This article will cover all the steps needed for adding new data to your app:
- Creating a data model
- Adding a collection of data to our MasterPage
- Adding data to our collection
In this article we will use a set of people as our data
First we need to create a model of our data.
Our model will be named Person and contain the properties Id, FirstName, LastName, Email, Country.
To create the model follow these steps:
- Load your app in Aquro App Studio
- Navigate to the DATA MODELS pane (located in the top menu)
- Right click on the Models node in the treeview to the left
- Click on Add model
- Enter Person as the name and then click on OK
- The model is now created
- Click on ADD to add a new property to the model
- Type FirstName into the textbox
- Repeat step 7 and 8 for the properties LastName, Email and Country
- Click on SAVE to save your model
In this example we will create a collection of Person data items that should be accessible from all pages in our app for later usage. Therefore we will create a collection that is Public and we will store it in the MasterPage.
To add the collection to the MasterPage follow these steps:
- Navigate the the Development pane (located in the top menu)
- Expand the Pages node in the treeview and locate the MasterPage
- Click on the MasterPage to load the MasterPage into the view.
- Click on the DATA tab
- Click on ADD
- The "Add data" wizard will now load
- Select New data collection and click on Next
- In the drop down select the Person model and click on Next
- Select Global as scope as we like this collection to be available from all pages and click on Next
- Select Store in database as we like to store the data in this collection even if the app closes then click Next
- Type Persons as the name of this collection and then click Next
- Your collection will now be created and you will see the collection in the list of DataObjects.
- Click on SAVE to save this collection to the page
Data in collections may be populated in a few different ways. The data may be manually pre populated by adding items when the app is created, added by Visual Coding Scripts, added by custom JavaScript or may be synced with data from the cloud.
In this article we will populate the collection with data manually by adding the data inside Aquro App Studio.
To add data to your collection follow these steps:
- Locate the DataObject called Persons in the list of DataObjects (found in the MasterPage under the tab DATA).
- Click on the row of the DataObject called Persons
- A property window to the right will now show the properties of the DataObject.
- Click on the tab DATA and you will see a list an empty list.
- To add a new data item to the collection click ADD
- A new row will now be added to the list. The row will contain of one textbox for each property from the model Person.
- Enter the following data
FirstName = John
LastName = Doe
Email = john.doe@aquro.com
Country = USA
- Click on the ADD button to add a new row of data and enter the following values:
FirstName = Jane
LastName = Doe
Email = jane.doe@aquro.com
Country = SWEDEN
- Click on SAVE to save the data to the page
You may also use Visual Coding Scripts to add data to your collection. This is described in a separate article found here.
You have now added a new Data Model, a collection and populated the collection with data items in your app.