我创建了一个Angular指令来为KendoGrid设置默认设置。我设置了可排序,可调整大小,可过滤和可重新排序的属性,并且效果很好。我尝试为[columnMenu]设置默认设置时遇到问题。设置将被完全忽略。
// -----------------------------
// default-settings.directive.ts
// -----------------------------
import { Directive, OnInit } from '@angular/core';
import { GridComponent, ColumnMenuSettings } from '@progress/kendo-angular-grid';
@Directive({
selector: '[appDefaultSettings]'
})
export class DefaultSettingsDirective implements OnInit {
defaultColumnMenu: ColumnMenuSettings = {
sort: false,
filter: false,
lock: false,
columnChooser: true
}
sortable: boolean = true;
resizable: boolean = true;
filterable: boolean = true;
reorderable: boolean = true;
constructor(
private grid: GridComponent,
) { }
private initializeDefaults() {
this.grid.sortable = this.sortable;
this.grid.resizable = this.resizable;
this.grid.filterable = this.filterable;
this.grid.reorderable = this.reorderable;
this.grid.columnMenu = this.defaultColumnMenu;
}
ngOnInit(): void {
this.initializeDefaults();
}
}
// -----------------------------
// app.component.ts
// -----------------------------
import { Component } from '@angular/core';
import { customers } from './customers';
@Component({
selector: 'my-app',
template: `
<kendo-grid appDefaultSettings
[kendoGridBinding]="data"
[height]="410">
</kendo-grid>
`
})
export class AppComponent {
public data: any[] = customers;
constructor() {
}
}
这里是StackBlitz link的完整示例。
感谢您的帮助。