【发布时间】:2019-11-20 03:23:56
【问题描述】:
我有一个 Master-Detail ag-grid。一列有复选框,(checkboxSelection: true)。详细信息网格有一个带有按钮的自定义状态面板。当用户单击任何特定详细信息网格中的按钮时,我不知道如何从该特定详细信息网格中获取 SelectedRows。
问题是它们可能会显示/打开多个详细信息,然后循环遍历每个详细信息网格将包括来自所有打开网格的结果。我试图隔离到用户单击按钮的网格。
我尝试遍历所有显示/打开的详细信息网格以获取详细信息网格 ID。但我没有看到任何信息显示他们点击了哪个按钮。
我尝试在按钮组件中查看参数中是否有任何引用按钮所在的 detailgrid ID 的内容,但我也没有看到任何内容。
这是按钮组件:
function ClickableStatusBarComponent() {}
ClickableStatusBarComponent.prototype.init = function(params)
{
this.params = params;
this.eGui = document.createElement('div');
this.eGui.className = 'ag-name-value';
this.eButton = document.createElement('button');
this.buttonListener = this.onButtonClicked.bind(this);
this.eButton.addEventListener("click", this.buttonListener);
this.eButton.innerHTML = 'Cancel Selected Records <em class="fas fa-check" aria-hidden="true"></em>';
console.log(this.params);
this.eGui.appendChild(this.eButton);
};
ClickableStatusBarComponent.prototype.getGui = function()
{
return this.eGui;
};
ClickableStatusBarComponent.prototype.destroy = function()
{
this.eButton.removeEventListener("click", this.buttonListener);
};
ClickableStatusBarComponent.prototype.onButtonClicked = function()
{
getSelectedRows();
};
下面是循环查找所有打开的细节网格的代码:
function getSelectedRows()
{
this.gridOptions.api.forEachDetailGridInfo(function(detailGridApi) {
console.log(detailGridApi.id);
});
【问题讨论】:
标签: javascript ag-grid master-detail