從 PowerApps 中的資料表顯示、編輯或新增記錄Show, edit, or add a record from a table in PowerApps

若要顯示某筆記錄中的所有欄位,請新增並設定一個顯示表單控制項。To show all fields in a record, add and configure a Display form control. 若要編輯某筆記錄中的任一欄位 (或新增記錄) 並將變更儲存回資料來源,請新增並設定一個編輯表單控制項。To edit any field in a record (or to add a record) and save your changes back to a data source, add and configure an Edit form control.

必要條件Prerequisites

新增表單,並顯示資料Add a form, and show data

  1. 新增一個下拉式清單控制項,將其命名為 ChooseProduct,然後將其 Items 屬性設定為此值:Add a Drop down control, name it ChooseProduct, and set its Items property to this value:

    FlooringEstimates.NameFlooringEstimates.Name

    注意︰如果您不確定如何新增控制項、將它重新命名或設定屬性,請參閱新增並設定控制項Note: If you're not sure how to add a control, rename it, or set a property, see Add and configure controls.

    此清單顯示資料來源中的地板材料產品名稱。The list shows names of flooring products from the data source.

  2. 新增一個編輯表單控制項,將它移到 ChooseProduct 之下,然後調整表單的大小以涵蓋大部分的螢幕。Add an Edit form control, move it below ChooseProduct, and then resize the form to cover most of the screen.

    新增表格

    注意︰本主題描述編輯表單控制項,但同樣的原則亦適用於顯示表單控制項。Note: This topic describes the Edit form control, but similar principles apply to the Display form control.

  3. 將表單的 DataSource 屬性設為 FlooringEstimates,並將表單的 Item 屬性設為以下公式︰Set the DataSource property of the form to FlooringEstimates and the Item property of the form to this formula:

    First(Filter(FlooringEstimates, Name=ChooseProduct.Selected.Value))First(Filter(FlooringEstimates, Name=ChooseProduct.Selected.Value))

    這個公式指定在您完成表單設定後,它將顯示使用者在 ChooseProduct 中選取的記錄。This formula specifies that, after you finish configuring the form, it will show the record that the user selects in ChooseProduct.

  4. 在 [資料]窗格中,按一下或點選每個欄位的的核取方塊,以顯示欄位。In the Data pane, click or tap the checkbox for each field to show it.

    注意:如果 [資料] 窗格關閉,開啟方式為選取左側窗格中的表單,然後按一下或點選右側窗格中的 [資料]。Note: If the Data pane is closed, open it by selecting the form in the left-hand pane and then clicking or tapping Data in the right-hand pane.

    在表單上顯示欄位

  5. 在 [資料] 窗格中,將 [名稱] 項目拖曳到清單頂端。In the Data pane, drag the Name entry to the top of the list.

    移動卡片

    編輯表單控制項會反映您所做的變更。The Edit form control reflects your change.

    位於頂端的 [Name (名稱)]

設定欄位的卡片類型Set the card type for a field

  1. 選取表單,按一下或點選 [資料] 窗格中 [價格] 的卡片選取器。With the form selected, click or tap the card selector for Price in the Data pane.

    選取卡片選擇器

  2. 向下捲動,然後按一下或點選 [View Text (檢視文字)] 選項以將欄位設為唯讀。Scroll down, and then click or tap the View text option to make the field read-only.

    檢視文字

    表單會反映您所做的變更。The form reflects your change.

    唯讀的數字

(僅限編輯表單) 儲存變更(Edit form only) Save changes

  1. 在左側窗格中選取表單,然後按一下或點選省略符號 (...)。In the left-hand pane, select the form, and then click or tap the ellipsis (...).

    選取表單

  2. 按一下或點選 [重新命名],然後重新命名 EditForm 表單。Click or tap Rename, and then rename the form EditForm.
  3. 新增一個按鈕控制項,將其 Text 屬性設為 SaveAdd a Button control, and set its Text property to Save.

    新增儲存按鈕

  4. 將 [Save (儲存)] 按鈕的 OnSelect 屬性設為以下公式:Set the OnSelect property of the Save button to this formula:

    SubmitForm(EditForm)SubmitForm(EditForm)

  5. 選取右上角附近的播放按鈕 (或按 F5) 以開啟「預覽」模式。Open Preview mode by selecting the play button near the upper-right corner (or by pressing F5).

    開啟預覽模式

  6. 變更名稱的產品,然後按一下或點選您建立的 [Save (儲存)] 按鈕。Change the name of a product, and then click or tap the Save button that you created.

    SubmitForm 函式會將您的變更儲存到您設定表單所用的資料來源。The SubmitForm function saves your changes to the data source with which you configured the form.

  7. (選用) 選取關閉圖示以關閉「預覽」(或按 Esc)。(optional) Select the close icon to close Preview (or press Esc).

    關閉預覽

後續步驟Next steps