|
| 1 | +--- |
| 2 | +title: "Create and edit public model-driven app views | MicrosoftDocs" |
| 3 | +description: "Learn how to create or edit public or system model-driven app views." |
| 4 | +ms.date: 07/04/2021 |
| 5 | +ms.service: powerapps |
| 6 | +ms.subservice: mda-maker |
| 7 | +ms.topic: tutorial |
| 8 | +author: Joel-Lindstrom |
| 9 | +ms.author: v-ljoel |
| 10 | +ms.reviewer: matp |
| 11 | +--- |
| 12 | +# Create and edit public model-driven app views |
| 13 | + |
| 14 | +In Power Apps, views define how records for a specific table are displayed. A view defines the following behavior: |
| 15 | +- The columns, also known as attributes, to display. |
| 16 | +- The width of the columns in the view. |
| 17 | +- How the records are sorted by default. |
| 18 | +- Which filters are applied to determine the records that appear in the list by default. |
| 19 | + |
| 20 | +Typically, views are classified into three types: |
| 21 | +- **Personal**: Individual users can create personal views according to their unique requirements. These views are visible only to the user who created them and anyone they choose to share them with. |
| 22 | +- **Public**: As an app maker, you can create and edit public views to fit your organizational requirements. These views are available in the view selector, and you can use them in subgrids in a form or as a list in a dashboard. |
| 23 | +- **System**: As an app maker, you can also modify system views to meet the requirements of your organization. These are special views that the application depends on: they exist for system tables or are automatically created when you create custom tables. These views are available to some or all users, depending on their privileges. |
| 24 | + |
| 25 | +More information: [Understand model-driven app views](create-edit-views.md) |
| 26 | + |
| 27 | +A drop-down list of views is commonly displayed in an app so that people have options for different views of table data, such as the Donations table in the Fundraiser sample app. |
| 28 | +:::image type="content" source="media/create-or-edit-model-driven-app-view/system-views-picker.png" alt-text="Select a system view from the view picker."::: |
| 29 | + |
| 30 | +The records that are visible in individual views are displayed in a list, sometimes called a grid, which frequently provides options so that people can change the default sorting, column widths, and filters to more easily see the data that's important to them. Views also define the data source for charts that are used in the application. |
| 31 | + |
| 32 | +In this tutorial, we perform several tasks required to work with views, such as create a public view, add an existing view to an app, and change columns, filters, and sort order for a view. |
| 33 | + |
| 34 | +## Create a public view in Power Apps |
| 35 | + |
| 36 | +In this exercise, you create a public view for the account entity. You then add this view to an app. |
| 37 | + |
| 38 | +1. Sign in to [Power Apps](https://make.powerapps.com/?utm_source=padocs&utm_medium=linkinadoc&utm_campaign=referralsfromdoc). |
| 39 | + |
| 40 | +1. Expand **Data**, select **Tables**, select the **Account** table, and then select the **Views** tab. |
| 41 | + |
| 42 | +1. On the toolbar, select **Add view**. |
| 43 | + |
| 44 | +1. On the **Create a view** dialog box, enter *Accounts with revenue more than 50 K* as the **Name**. Optionally, enter a description, and then select **Create**. |
| 45 | + |
| 46 | +1. In the view designer, select **+ View column** and add the **Address1: City** column to the view. |
| 47 | + |
| 48 | + > [!TIP] |
| 49 | + > The **Default** view in the **Add column** pane displays the commonly used columns. If the column you want isn’t listed, select **All** to display additional columns. |
| 50 | +
|
| 51 | +  |
| 52 | + |
| 53 | +1. Repeat the previous step by selecting **Add column** and add the following additional columns to the view: |
| 54 | + - **Address 1: Country/Region** |
| 55 | + - **Address 1: Primary Contact** |
| 56 | + - **Annual Revenue** |
| 57 | + |
| 58 | +1. Change the column filtering for the **Annual Revenue** field by selecting the header of the column, and then in the dropdown select **Filter by**. Select **Greater than** for the operator and then enter *50000* for the value. Select **Apply**. |
| 59 | + :::image type="content" source="media/create-or-edit-model-driven-app-view/accounts-more-50k-rev.png" alt-text="Add a filter for accounts with more than 50,000 revenue."::: |
| 60 | + Notice the view in the designer reacts to the filter. |
| 61 | +1. Change the column sorting to sort by the most to least revenue. To do this, select the header of the **Annual Revenue** column, and then select **Larger to smaller**. Notice for text-based columns the sort options are **Sort A to Z** and **Sort Z to A**. |
| 62 | + |
| 63 | +1. Explore additional changes you can make to the view. |
| 64 | + - Increase a column width by selecting just to the right of the column heading you want to increase and drag the column to the right. |
| 65 | + - Reposition columns by dragging a column to the position you want to move it to. For example, select the **Primary Contact** column header and drag it between the **Account Name** and **Address 1: City** columns. |
| 66 | + |
| 67 | + > [!NOTE] |
| 68 | + > You can also change column order by selecting the column header and then select **Move Right** or **Move Left**. |
| 69 | +
|
| 70 | +1. Select **Save**, and then select **Publish** to make the view available for other users in the environment. |
| 71 | + |
| 72 | +## Add the view in the app designer |
| 73 | + |
| 74 | +1. In Power Apps, select **Apps** from the left navigation pane, select **...** next to the unmanaged app you want, and then select **Edit** > **Edit in preview**. If you don't have an app to use, [Build your first model-driven app](build-first-model-driven-app.md). |
| 75 | + |
| 76 | +1. In the **Pages** section of app designer, select **Account view**. |
| 77 | +1. In the right **Properties** pane, select **Manage views**, select the following views, and then select **Save**. |
| 78 | + - **Active Accounts** |
| 79 | + - **Inactive Accounts** |
| 80 | + - **Accounts with revenue more than 50K** |
| 81 | + :::image type="content" source="media/create-or-edit-model-driven-app-view/select-view-for-app.png" alt-text="Select the views you want to display"::: |
| 82 | +1. Select **Publish** to save and publish the app. |
| 83 | + |
| 84 | +### Display the view in an app |
| 85 | + |
| 86 | +To see your view in the app, on the app designer command bar, select **Play**. Notice that the view is displayed and the additional **Active Accounts** and **Inactive Accounts** views are also available by selecting the view selector. |
| 87 | +:::image type="content" source="media/create-or-edit-model-driven-app-view/view-displayed-in-app.png" alt-text="Views available from an app"::: |
| 88 | + |
| 89 | +## Open and add the view in the classic app designer |
| 90 | + |
| 91 | +1. In Power Apps, select **Apps** from the left navigation pane, select **...** next to the unmanaged app you want, and then select **Edit** . If you don't have an app to use, [Build your first model-driven app](build-first-model-driven-app.md). |
| 92 | + |
| 93 | +1. In the app designer **Entity View** section, select **Views**. |
| 94 | + |
| 95 | +  |
| 96 | + |
| 97 | +1. On the right **Components** tab, by default, all views are selected. To select specific views to display in the app, clear the **All** checkbox. |
| 98 | + |
| 99 | +  |
| 100 | + |
| 101 | +1. To add an existing view to your app, select it from the list of views, or to create a new view from the app designer, select **Create New**. |
| 102 | + |
| 103 | + > [!NOTE] |
| 104 | + > Views are displayed based on the table that you have selected. For example, when you select **Account**, views that are related to the account table are displayed. |
| 105 | +
|
| 106 | +### Add a column to your view in the classic app designer |
| 107 | + |
| 108 | +Views display records from a table that contains rows and columns. Each record is a row, and the columns that are displayed from the record are determined by the columns you add to the view. |
| 109 | + |
| 110 | +1. In app designer, select **Views**, then on the right **Components** pane place your mouse cursor over the view, and then select **edit** (pencil button). |
| 111 | + :::image type="content" source="media/create-or-edit-model-driven-app-view/edit-view.png" alt-text="Edit a view"::: |
| 112 | +1. On the **Components** tab in the view designer, select the **Column Attributes** list for the **Primary Entity**. |
| 113 | + |
| 114 | +  |
| 115 | + |
| 116 | +1. From the list of columns, select the column you want, such as the **Address 1: State/Province** column,and drag it to the view heading. You can also add the column by double-clicking it. |
| 117 | + :::image type="content" source="media/create-or-edit-model-driven-app-view/add-address1-state-column.png" alt-text="Add the Address 1: State/Province column to the view"::: |
| 118 | +1. Repeat step 3 until you've added all the columns you want to display in your view. As you add columns, you can drag them to any position among existing column headings. You can also move columns around after you add them to your view by dragging the column heading to the column heading where you want to move it. |
| 119 | +1. Select **Save and Close** on the command bar, to save the view and return to the app designer. |
| 120 | + |
| 121 | +### Define filter criteria in the classic app designer |
| 122 | + |
| 123 | +You can set filter criteria so that only a subset of the records is displayed in a view. When a user opens the view, only the records that meet the defined filter criteria are displayed. You can select columns from both the primary and related tables to filter on. |
| 124 | + |
| 125 | +1. In app designer, select **Views**, then on the right **Components** pane place your mouse cursor over the view, and then select edit (pencil button). |
| 126 | + :::image type="content" source="media/create-or-edit-model-driven-app-view/edit-view.png" alt-text="Edit a view"::: |
| 127 | +1. In the view designer, expand the **Filter Criteria** section, and then select **Add Filter**. |
| 128 | + |
| 129 | +  |
| 130 | + |
| 131 | +1. Select the **Address1: State/Province** column from the drop-down list in the first column. |
| 132 | + |
| 133 | +1. Select the **Equals** operator from the drop-down list in the second column. |
| 134 | + |
| 135 | +1. Enter *TX* as the value to filter by in the third column. |
| 136 | + |
| 137 | +  |
| 138 | + |
| 139 | + Notice how the view now shows accounts with annual revenue greater than $50,000 in the state of Texas (TX). |
| 140 | +1. Select **Save and Close** on the command bar, to save the view and return to the app designer. |
| 141 | +<!-- You can also filter data based on the attributes of related tables in addition to the |
| 142 | +primary table. |
| 143 | +
|
| 144 | +1. On the **Components** tab, select the **Column Attributes** list for **Related Table**, select a related table from the drop down list, and then choose the table you want. This will add a separate section. |
| 145 | + |
| 146 | +2. Repeat steps 2 through 5 from the previous procedure. |
| 147 | +
|
| 148 | +More information: [Create and edit relationships between tables](https://docs.microsoft.com/powerapps/maker/data-platform/create-edit-entity-relationships) --> |
| 149 | + |
| 150 | +#### Group multiple filters in the classic app designer |
| 151 | + |
| 152 | +You can add multiple filters to your view if you want to filter records by using more than one column. |
| 153 | + |
| 154 | +1. Select the filters that you want to group. |
| 155 | +  |
| 156 | + |
| 157 | +1. Select **Group And** or **Group Or** to group the filters. |
| 158 | +  |
| 159 | + |
| 160 | + When you select **Group And**, only records that meet both criteria are displayed in the view. When you select **Group Or**, records that meet any of the filter criteria are displayed. For example, to show only records that have priority of **High** or **Normal**, and a status of **Active**, select **Group And**. |
| 161 | + |
| 162 | +To remove the filter from a group, select the group, and then select **Ungroup**. |
| 163 | + |
| 164 | +### Set primary and secondary sort order for columns in the classic app designer |
| 165 | + |
| 166 | +When a view is opened, the records displayed are sorted in the order you set when you created the view. By default, records will be sorted according to the first column in a view when no sort order is selected. You can choose to sort on a single column, or you can choose two columns—one primary and one secondary—to sort by. When the view is opened, the records are first sorted by the column you want to use for primary sort order, and then by the column you want to use for the secondary sort order. |
| 167 | + |
| 168 | +> [!NOTE] |
| 169 | +> You can only set primary and secondary sort order for column attributes you added from the primary table. |
| 170 | +
|
| 171 | +1. In app designer, select **Views**, then on the right **Components** pane place your mouse cursor over the view, and then select edit (pencil button). |
| 172 | + :::image type="content" source="media/create-or-edit-model-driven-app-view/edit-view.png" alt-text="Edit a view"::: |
| 173 | +1. In the **Columns** area of the view designer, select the column heading you want to use for sorting, such as **Business Phone**, select the down arrow, and then choose **Primary Sort** or **Secondary Sort**. |
| 174 | + |
| 175 | +  |
| 176 | + |
| 177 | +If you remove the column you chose for the primary sort order, the column you chose for the secondary sort order becomes the primary. |
| 178 | + |
| 179 | +### Edit an active public or system view in app designer |
| 180 | + |
| 181 | +You can change the way an active public or system view is displayed that's selected for the app by opening it from the app designer canvas. |
| 182 | + |
| 183 | +1. In the **Views** list for a table, select the **Show list of references** down arrow |
| 184 | + . |
| 185 | + > [!NOTE] |
| 186 | + > The down arrow is only displayed when the table views are not configured to use **All** views. |
| 187 | +
|
| 188 | +1. Select the active view  that you want to open for editing. |
| 189 | + |
| 190 | +  |
| 191 | + |
| 192 | +When you edit a public or system view, you must save and publish your changes before they will be visible in the application. |
| 193 | + |
| 194 | +### See also |
| 195 | + |
| 196 | +[Create a model-driven app with the app designer](create-model-driven-app.md) <br /> |
| 197 | +[Design custom business apps by using the app designer](design-custom-business-apps-using-app-designer.md) |
0 commit comments