編輯

共用方式為


GridAttribute (Client API reference)

GridAttribute is supported for both read-only and editable grids.

GridAttribute represents the data in the cell of an editable grid, and contains a reference to all the cells associated with the column. See Collections (Client API reference) for information on the methods available to access data in a collection.

GridAttribute also supports the controls collection for columns of a selected grid row, which provides methods to work with a collection of cells associated with the column. Each cell (GridCell) of a selected grid row is analogous to a control on a form that is tied to a column in an editable grid. See Collections (Client API reference) for information on the methods available to access data in a collection.

Tip

For performance reasons, a row (record) in an editable grid is not editable until the record is selected. Users must select a single record in a grid to edit it. Once a record is selected in an editable grid, Dynamics 365 internally evaluates a number of things including user access to the record, whether the record is active, and column validations to ensure that data security and validity are honored when you edit data. Consider using the OnRecordSelect event with the getFormContext method to access records in the grid that are in the editable state.

Methods

GridAttribute supports the following methods for columns of a selected grid row.

Name Description
getName Returns the logical name of the column of a selected grid row.
getRequiredLevel Returns a string value indicating whether a value for the column is required or recommended.
setRequiredLevel Sets whether data is required or recommended for the column of a selected grid row before the record can be saved.
getValue Retrieves the data value for a column.
setValue Sets the data value for a column.

Note

To select a row in an editable grid, use the Grid.getSelectedRows

GridCell
Grids and subgrids in model-driven apps
Controls collection