Customize Blank Gallery in Power Apps for Todo Application
Hi, in my previous post, you have learned about how to make simple Todo App in Power Apps with simple text input, button and preformatted vertical gallery. In this post, we'll be learning about how to customize the gallery rows to have a label and two buttons for completion status and edit task using a blank flexible height gallery.
First, this is how the table will be:
Second, let's prepare our UI.
- Now, click on Insert and search for "Blank flexible height gallery". Drag it to the UI.
- Then, it will ask you to connect to a data source. Select your table and connect.
- Now there is a small pen icon on top-left corner. Click it to customize one row of it.
- Now, insert a label into the gallery row. Resize it according to your needs.
- In order to display items from the table in the label, edit the `Text` property of the label and enter Fx code: `ThisItem.<column_name>` so here, it would be `ThisItem.Task`.
Here's how it looks till now:
- Now, we need to add two icons for "completed" and "edit". So, click on the gallery row and click on Insert > Icon > Select 'Check' icon and Select 'Edit' icon.
- Place and resize icons according to you on the row.
Here's how it will look:
- Now, the requirement is, clicking on 'Check' icon, it should update the `Completed` row in table to true and also make the row background to green and on click on 'Edit' icon, it should open a new screen for us to be able to edit the details and update it in the table.
Steps for Check icon functionality:
- Click on the check icon and edit its `OnSelect` property to:
Patch(TodoApps, LookUp(TodoApps, 'Task'=Gallery1.Selected.Task), {Completed: true});
Steps for Edit Icon functionality:
- Let's add another screen to our app and rename it to "EditTaskScreen".
- The UI for the EditTaskScreen will look like this. You can customize the UI according to you.
- Click the Edit Icon button, edit its `OnSelect` property to:
Navigate(EditTaskScreen,ScreenTransition.Fade, {taskName: ThisItem.Task, completedStatus: ThisItem.Completed})
- Here, we are passing the context variables in the third argument of Navigate(). This will help us get data to another screen.
- Now, edit the `Default` property of the label on EditTaskScreen to taskName and do the same to the toggle button for status to `completedStatus`.
- Edit the `OnSelect` property of `UpdateTask` button on EditTaskScreen to:
Patch(TodoApps, LookUp(TodoApps, 'Task'=taskName), {Task: TextInputTask.Text, Completed: toggleStatus.Value});
Let's look at the final app:
Comments
Post a Comment