Javascript ag网格中的列关联菜单复选框切换
我正在尝试为ag网格中的整列添加上下文菜单复选框。Javascript ag网格中的列关联菜单复选框切换,javascript,datagrid,ag-grid,Javascript,Datagrid,Ag Grid,我正在尝试为ag网格中的整列添加上下文菜单复选框。 通过遵循教程,我可以通过设置checked:true将复选框添加到自定义菜单中,但这不是一个可切换的复选框。它始终仅设置为true。如何使其可切换?首先您必须定义网格选项的上下文,如下所示:上下文:{thisComponent:this} public gridOptions: any = { columnDefs: this.columnDefs, rowData: this.rowData, enableSorting:
通过遵循教程,我可以通过设置
checked:true
将复选框添加到自定义菜单中,但这不是一个可切换的复选框。它始终仅设置为true。如何使其可切换?首先您必须定义网格选项的上下文,如下所示:上下文:{thisComponent:this}
public gridOptions: any = {
columnDefs: this.columnDefs,
rowData: this.rowData,
enableSorting: false,
enableFilter: false,
context: { thisComponent: this }
}
然后您必须创建自己的函数,该函数返回true或false:
public checkedContextMenuFunction(params): boolean {
if (){
return true;
}else {
return false;
}
}
并将其添加到contextMenuItems函数中:
选中:params.context.thisComponent.checkedContextMenuFunction(params)
public getContextMenuItems(params) {
return{
'separator',
{
name: 'Checked menu',
tooltip: 'Tooltip text',
checked: params.context.thisComponent.checkedContextMenuFunction(params),
action: function() {
params.context.thisComponent.differentFunction(params);
}
}
}
首先,必须按如下方式定义网格选项的上下文:context:{thisComponent:this}
public gridOptions: any = {
columnDefs: this.columnDefs,
rowData: this.rowData,
enableSorting: false,
enableFilter: false,
context: { thisComponent: this }
}
然后您必须创建自己的函数,该函数返回true或false:
public checkedContextMenuFunction(params): boolean {
if (){
return true;
}else {
return false;
}
}
并将其添加到contextMenuItems函数中:
选中:params.context.thisComponent.checkedContextMenuFunction(params)
public getContextMenuItems(params) {
return{
'separator',
{
name: 'Checked menu',
tooltip: 'Tooltip text',
checked: params.context.thisComponent.checkedContextMenuFunction(params),
action: function() {
params.context.thisComponent.differentFunction(params);
}
}
}