有沒有爲每行設置行選擇複選框而不爲其配置特殊列的方法?我的意思是爲我的gridOptions添加propertie並在每行附近查看複選框,然後獲取所有選定的行? 我閱讀的所有文檔都顯示瞭如何將其添加到特定列中。如何爲Ag-grid添加行選擇複選框
感謝,
有沒有爲每行設置行選擇複選框而不爲其配置特殊列的方法?我的意思是爲我的gridOptions添加propertie並在每行附近查看複選框,然後獲取所有選定的行? 我閱讀的所有文檔都顯示瞭如何將其添加到特定列中。如何爲Ag-grid添加行選擇複選框
感謝,
你可以有行選擇仍然無需一個複選框列 - 你可以簡單地選擇基於行選擇,或有一列在它一個複選框渲染(具有自定義單元格渲染器) 。
看看在Selection Documentation約行選擇更多的信息,並在Cell Rendering Documentation約細胞呈現
我知道這是爲時已晚來回答這個職位。但它可能會幫助那些仍然在尋找解決方案的人。它適用於每行上的複選框選擇(單擊行的任意位置以選中複選框),移動/控制和切換選擇。這裏我只給出了必要的代碼。
vm.gridOptions = {
appSpecific : {},
onRowClicked : onRowClicked,
onGridReady : function() {
let api = vm.gridApi = vm.gridOptions.api;
}
};
function toggleSelect(row) {
row.node.setSelected(!row.node.isSelected(), false);
}
function onRowClicked(row) {
var appSpecific = vm.gridOptions.appSpecific;
var lastSelectedRow = appSpecific.lastSelectedRow;
var shiftKey = row.event.shiftKey;
// if not modifier keys are clicked toggle row
if (!shiftKey) {
toggleSelect(row);
} else if (lastSelectedRow !== undefined) {
if (shiftKey) {
var startIndex, endIndex;
// Get our start and end indexes correct
if (row.rowIndex < lastSelectedRow.rowIndex) {
startIndex = row.rowIndex;
endIndex = lastSelectedRow.rowIndex;
}
else {
startIndex = lastSelectedRow.rowIndex;
endIndex = row.rowIndex;
}
// Select all the rows between the previously selected row and the
// newly clicked row
for (var i = startIndex; i <= endIndex; i++) {
vm.gridApi.selectIndex(i, true, true);
}
}
}
// Store the recently clicked row for future use
appSpecific.lastSelectedRow = row;
getSelection(); // Implement functionality to get selected rows
}
ag-grid沒有api來選擇整行通過複選框? – user2095956
您可以對cellClicked或rowClicked等事件做出反應,一旦調用,您可以依次調用node.setSelected(true)(例如) –
好的......謝謝。我們還希望購買ag-grid許可證以使用您的某些企業功能,但我發現這並不容易,您可以聯繫我與您的銷售嗎? – user2095956