Edit Your Data
In the previous article, Display Your Data, you displayed data from a data source in an app. In this article, you update your app to edit data.
You typically edit data in Form screen. In this example, you modify the contacts Summary screen, which is implemented as a Form screen, to edit your data.
In this article, you will:
- Modify the Summary screen to let you edit data.
- Edit app data in a simulator.
Modify the Summary screen to let you edit data
When you create an editable screen, you let the user modify data and then upload those changes back to the entity associated with the screen. You typically include a Button control to trigger the upload of the modified data back to the entity, but there are other ways to trigger the upload.
The contacts Summary screen in your app contains two Date Field controls, for LastActivityDate and Last TranDate, and Text Box controls for all other data. Each of these controls is associated with a single field in the data entity assigned to the screen. For example, the FirstName Text Box control is associated with the contacts.FirstName entity field.
In a Form screen, you can individually control whether or not a field can be edited. In this example, you make the FirstName, LastName, and PhoneMobil controls editable, and add a Button control to trigger the upload. When you upload your changes, the new values in the editable controls are written to their corresponding entity fields.
To edit entity data:
- Start AppStudio.
- Load the HelloWorld app.
- In the Application Explorer, open the contacts Summary form at Views > Form > contacts Summary.
- Delete the LastActivityDate, LastrTransDate, Latitude, and Longitude controls in the contacts Summary form. These controls are not necessary for this app.
- Select the FirstName Text Box control.
- In the Poperties area, select Editable.
- Make the LastName and PhoneMobile controls editable, too.
- Add a Button control to the bottom of the view with the following properties:
- Label: Save
- Screen Alignment: Center
- Action: Save
- Target Screen: contacts List (Default)
- Target View: contacts List
- Save the app.
The Button control triggers the upload, and also navigates the app from the contacts Summary screen back to the List screen that shows all contacts.
Edit app data in a simulator
Now that you have added editing to the app, run it in the simulator.
To run the app:
- Start the Hello World app in the simulator.
- Click the Show Contacts button to display the List screen showing all contacts.
- Select a contact, for example, select Deb Vitter at Sal's Pizza. The contacts Summary screen appears.
- Select the FirstName field and change 'Deb' to 'Debby'.
- Select the PhoneMobile field, the second of the three phone numbers, and change the number.
Click the Save button. Your changes are uploaded and you return to the List screen. Notice that Deb's name now shows Debby.
Depending on your simulator, the your data changes might not appear immediately.
Where to next