簡體   English   中英

如何將 selectAll 和 deSelectAll 應用於 ag-grid react 中的 header 復選框

[英]how to apply selectAll and deSelectAll to the header checkbox in ag-grid react

我已將 checkboxSelection 添加到我的第一列以及 headerCheckBoxSelection。

columnDefs: [
  {
    minWidth: 45,
    maxWidth: 45,
    headerCheckboxSelection: true,
    checkboxSelection: true,
    lockPosition: true,
    hide: selectedHeaders.length === 0 ? true : selectedHeaders.includes('Name')
  },

但是 select 和 deseltall 的 header 復選框不起作用。 我為 selectAll 和 deselectAll 添加了兩個回調,但我不確定在哪里添加這些回調,以便我可以 select 並取消選擇所有行:

const deselectAllHandler = useCallback(() => {
 gridApi.deselectAll();
}, [gridApi]);

const selectAllHandler = useCallback(() => {
 gridApi.selectAll();
}, [gridApi]);

我能夠 select 單個復選框並檢索選定的行,但無法 select 全部並取消選擇所有

在此處輸入圖像描述

提前致謝!

抱歉,我一直在使用的 Grid 組件是一個共享組件,有人在該復選框上禁用了鼠標單擊。 因此,此屬性 headerCheckboxSelection: true 足以允許 select 並取消全選。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM