PowerApps 中的数据表控件Data table control in PowerApps

以表格格式显示一组数据。Shows a set of data in a tabular format.

说明Description

“数据表”控件显示数据集,格式为控件显示的每个字段都有对应的列标题。The Data table control shows a dataset in a format that includes column headers for each field that the control shows. 作为应用开发者,可以完全控制显示哪些字段和显示顺序。As an app maker, you have full control over which fields appear and in what order. 与“库”控件一样,“数据表”控件包含指向选定行的“Selected”属性。Like the Gallery control, the Data table control maintains a Selected property that points to the selected row. 因此,可以将“数据表”控件与其他控件相关联。Therefore, you can link the Data table control to other controls.

功能Capabilities

PowerApps 在 2017 年 5 月 5 日引入了“数据表”控件。PowerApps introduced the Data table control on May 5, 2017. 此部分介绍了支持和不支持的功能。This section provides information about capabilities that are supported and capabilities that aren't supported.

现可用Now available

  • “数据表”控件中的数据为只读。Data in a Data table control is read-only.
  • “数据表”控件中始终都会选择一行。A single row is always selected in a Data table control.
  • 将“数据表”控件链接到已连接或本地数据源。Link a Data table control to a connected or local data source.
  • 运行应用的同时,在“数据表”控件中调整列宽度,尽管不会保存所做的更改。Adjust column widths in a Data table control while you run the app, though your changes aren't saved.
  • 将“数据表”控件链接到已实现此功能的连接器(如 Common Data Service)时,将显示一组默认字段。A set of default fields appear in a Data table control when you link it to a connector that has implemented this capability, such as the Common Data Service. 然后,可以根据需要显示或隐藏这些字段以及其他内容。You can then show or hide these fields and others as necessary.
  • 自定义列宽度和标题文本。Customize column width and heading text.
  • 在“数据表”控件中显示超链接。Show hyperlinks in a Data table control.
  • 复制并粘贴“数据表”控件。Copy and paste a Data table control.

尚未推出Not yet available

  • 自定义各列的样式。Customize the styling of individual columns.
  • 在“表单”控件中添加“数据表”控件。Add a Data table control in a form control.
  • 更改所有行的高度。Change the height of all rows.
  • 在“数据表”控件中显示图像。Show images in a Data table control.
  • 显示相关实体中的字段。Show fields from related entities.
  • 使用内置功能按列标题对数据进行筛选和排序。Use built-in functionality to filter and sort data by column heading.
  • 在“库”控件中添加“数据表”控件。Add a Data table control in a Gallery control.
  • 编辑“数据表”控件中的数据。Edit data in the Data table control.
  • 选择多行。Select multiple rows.

已知问题Known issues

  • 如果在“Items”属性中使用“FirstN”函数,不会显示任何数据。No data appears if you use the FirstN function in the Items property.

关键属性Key properties

  • Items -“数据表”控件中显示的数据源。Items – The source of data that appears in the Data table control.
  • Selected -“数据表”控件中的选定行。Selected – The selected row in the Data table control.

其他属性Other properties

  • BorderColor -“数据表”控件边框颜色。BorderColor – The color of the Data table control's border.
  • BorderStyle -“数据表”控件边框样式。BorderStyle – The style of the Data table control's border. 选项包括 Solid、Dashed、Dotted 和 None。The options are Solid, Dashed, Dotted, and None.
  • BorderThickness -“数据表”控件边框粗细。BorderThickness – The thickness of the Data table control's border.
  • Color - 所有数据行的默认文本颜色。Color – The default text color for all data rows.
  • Fill - 所有数据行的默认背景色。Fill – The default background color for all data rows.
  • Font - 所有数据行的默认字体。Font - The default font for all data rows.
  • FontWeight - 所有数据行的默认字体粗细。FontWeight – The default font weight for all data rows.
  • HeadingColor - 列标题的文字颜色。HeadingColor – The text color for the column headings.
  • HeadingFill - 列标题的背景色。HeadingFill – The background color of the column headings.
  • HeadingFont - 列标题的字体。HeadingFont – The font of the column headings.
  • HeadingFontWeight - 列标题的字体粗细。HeadingFontWeight – The font weight of the column headings.
  • HeadingSize - 列标题的字号。HeadingSize – The font size of the column headings.
  • Height -“数据表”控件上下边缘之间的距离。Height – The distance between the Data table control's top and bottom edges.
  • HoverColor - 鼠标指针指向的行的文字颜色。HoverColor – The text color for the row that the mouse pointer is pointing at.
  • HoverFill - 鼠标指针指向的行的背景色。HoverFill – The background color of the row that the mouse pointer is pointing at.
  • NoDataText -“数据表”控件中没有记录可显示时向用户显示的消息。NoDataText – The message that the user receives when there are no records to show in the Data table control.
  • SelectedColor - 用户选择的行的文本颜色。SelectedColor – The color of the text in the selected row.
  • SelectedFill - 用户选择的行的背景色。SelectedFill – The background color of the selected row.
  • Size - 所有数据行的默认字号。Size – The default font size for all data rows.
  • Visible - 用于确定“数据表”控件是否可见的值。Visible – A value that determines whether the Data table control appears or is hidden.
  • Width -“数据表”控件左右边缘之间的距离。Width – The distance between the Data table control's left and right edges.
  • X -“数据表”控件左边缘与其父容器左边缘(如果没有父容器,则为屏幕左边缘)之间的距离。X – The distance between the left edge of the Data table control and the left edge of its parent container (or the left edge of the screen if there is no parent container).
  • Y -“数据表”控件上边缘与其父容器上边缘(如果没有父容器,则为屏幕上边缘)之间的距离。Y – The distance between the top edge of the Data table control and the top edge of its parent container (or the top edge of the screen if there is no parent container).

示例Examples

基本用法Basic usage

  1. 创建一个空白的平板电脑应用。Create a blank tablet app.
  2. 在“插入”选项卡上,单击或点击“数据表”。On the Insert tab, click or tap Data table.

    在屏幕中添加“数据表”控件

    “数据表”控件已添加到屏幕中。A Data table control is added to the screen.

  3. 将“数据表”控件重命名为“SalesOrderTable”,再重设大小,使其全屏显示。Rename the Data table control SalesOrderTable, and resize it so that it covers the whole screen.
  4. 在右侧窗格中,依次单击或点击“未选择数据源”文本右侧的向下箭头和“添加数据源”。In the right pane, click or tap the down arrow to the right of the No data source selected text, and then click or tap Add a data source.

    添加数据源

  5. 在连接列表中,单击或点击 Common Data Service 数据库的连接。In the list of connections, click or tap the connection for your Common Data Service database.

    为数据源选择连接

  6. 在实体列表中,单击或点击“销售订单”,然后单击或点击“连接”。In the list of entities, click or tap Sales order, and then click or tap Connect.

    选择“销售订单”实体

    “数据表”控件现在与“销售订单”数据源相连。The Data table control is now attached to the Sales order data source. “数据表”控件中会显示多个初始字段,因为我们使用的连接器支持此功能。Several initial fields appear in the Data table control, because we're using a connector that supports that capability.

    数据表

  7. 在右侧窗格中,选中或取消选中一个或多个复选框,以显示或隐藏各个字段。In the right pane, select one or more check boxes to show or hide individual fields.

    例如,选中“CustomerPurchaseOrderReference”旁边的复选框可以显示此字段。For example, select the check box next to CustomerPurchaseOrderReference to hide this field.

  8. 在右侧窗格中,上下拖动字段,以重新排列。In the right pane, reorder the fields by dragging them up or down.

    根据需要对字段进行重新排序

    此时,“SalesOrderTable”控件按所指定的顺序显示字段。The SalesOrderTable control shows the fields in the order that you specified.

    更新后的数据表

重设“数据表”控件的列标题样式Restyle the header for the Data table control

  1. 选择“数据表”控件后,单击或点击右侧窗格中的“高级”选项卡。While the Data table control is selected, in the right pane, click or tap the Advanced tab.
  2. 单击或点击“HeadingFill”属性字段,然后将值更改为“RGBA(62,96,170,1)”。Click or tap the field for the HeadingFill property, and then change the value to RGBA(62,96,170,1).
  3. 单击或点击“HeadingColor”属性字段,再将值更改为“White”。Click or tap the field for the HeadingColor property, and then change the value to White.
  4. 单击或点击“HeadingSize”属性字段,然后将值更改为“14”。Click or tap the field for the HeadingSize property, and then change the value to 14.

    数据表

将“数据表”控件与其他控件相联Connect a Data table control to another control

  1. 将“编辑窗体”控件添加到屏幕中。Add an Edit form control to the screen.
  2. 重设“数据表”和“编辑表单”控件大小,让“数据表”控件显示在屏幕的左侧,并让“编辑表单”控件显示在屏幕的右侧。Resize the Data table and Edit form controls so that the Data table control appears in the left part of the screen and the Edit form control appears in the right part of the screen.

    “数据表”和“编辑表单”控件位于同一屏幕上

  3. 选择“Form1”的同时,在右侧窗格中将列数更改为“1”。While Form1 is selected, in the right pane, change the number of columns to 1.
  4. 将“Form1”与“销售订单”数据源相连。Connect Form1 to the Sales order data source.

    “Form1”中将显示多个初始字段。Several initial fields appear in Form1.

    包含初始字段的 Form1

  5. 在右侧窗格中,单击或点击“高级”选项卡。In the right pane, click or tap the Advanced tab.
  6. 将“Form1”的“Item”属性设置为“SalesOrderTable.Selected”。Set the Item property for Form1 to SalesOrderTable.Selected.

    此时,“Form1”控件显示“数据表”控件中选定行的相关信息。Form1 shows information from the row that's selected in the Data table control.

    与“数据表”控件相联的“编辑表单”控件