- 資料網格
- 日期和時間選擇器
- 圖表
- 樹狀檢視
按下 Enter 開始編輯
多選
使用 multiSelect
屬性來啟用多選。
- 資料網格
- 日期和時間選擇器
- 圖表
- 樹狀檢視
按下 Enter 開始編輯
停用選取
如果您不希望項目可選取,請使用 disableSelection
屬性
- 資料網格
- 日期和時間選擇器
- 圖表
- 樹狀檢視
按下 Enter 開始編輯
核取方塊選取
若要啟用核取方塊選取,請設定 checkboxSelection={true}
- 資料網格
- 日期和時間選擇器
- 圖表
- 樹狀檢視
按下 Enter 開始編輯
這也與多選相容
- 資料網格
- 日期和時間選擇器
- 圖表
- 樹狀檢視
按下 Enter 開始編輯
- 資料網格
- 日期和時間選擇器
- 圖表
- 樹狀檢視
按下 Enter 開始編輯
追蹤項目選取變更
如果您想要對項目選取變更做出反應,請使用 onItemSelectionToggle
屬性
未記錄項目選取
- 資料網格
- 日期和時間選擇器
- 圖表
- 樹狀檢視
按下 Enter 開始編輯
父項/子項選取關係
當某個項目的所有子項目都被選取時自動選取該項目,以及當父項目被選取時自動選取所有子項目。
如果您無法升級,您可以使用 selectedItems
、onSelectedItemsChange
和 onItemSelectionToggle
屬性建立自己的自訂解決方案
- 資料網格
- 日期和時間選擇器
- 圖表
- 樹狀檢視
按下 Enter 開始編輯
命令式 API
選取或取消選取項目
使用 selectItem
API 方法來選取或取消選取項目
apiRef.current.selectItem({
// The DOM event that triggered the change
event,
// The id of the item to select or deselect
itemId,
// If `true`, the other already selected items will remain selected
// Otherwise, they will be deselected
// This parameter is only relevant when `multiSelect` is `true`
keepExistingSelection,
// If `true` the item will be selected
// If `false` the item will be deselected
// If not defined, the item's new selection status will be the opposite of its current one
shouldBeSelected,
});
- @mui/x-data-grid
- @mui/x-data-grid-pro
- 日期和時間選擇器
- 圖表
- 樹狀檢視
當使用 multiSelect
時,您可以使用 keepExistingSelection
屬性來避免遺失已選取的項目
- @mui/x-data-grid
- @mui/x-data-grid-pro
- 日期和時間選擇器
- 圖表
- 樹狀檢視