簡體   English   中英

AG-Grid 標題單元格選擇

[英]AG-Grid Header Cell Selection

我正在嘗試創建一個 AG 網格來分配權限,其中標題選擇應選擇該列中的所有可用單元格。

它應該是這樣的: 在此處輸入圖片說明

一種方法是使用 HTML 模板和 Cell-Renderer 為行創建標題。

有沒有辦法使用 AG-Grid 屬性或 API 來實現這一點?

Ag-grid 文檔中有一個標題復選框選擇示例。

標題復選框選擇

可以在標題中有一個復選框以供選擇。 要將列配置為具有復選框,請設置 colDef.headerCheckboxSelection=true。 headerCheckboxSelection 也可以是一個函數,如果您希望復選框有時出現(例如,如果列在網格中排在第一位)。

// the name column header always has a checkbox in the header
colDef = {
    field: 'name',
    headerCheckboxSelection: true
    ...
}

// the country column header only has checkbox if it is the first column
colDef = {
    field: 'country',
    headerCheckboxSelection: function(params) {
        var displayedColumns = params.columnApi.getAllDisplayedColumns();
        var thisIsFirstColumn = displayedColumns[0] === params.column;
        return thisIsFirstColumn;
    }
    ...
}

暫無
暫無

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

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