【问题标题】:Disable opening context menu in Kendo for Angular在 Kendo for Angular 中禁用打开上下文菜单
【发布时间】:2019-04-26 19:40:23
【问题描述】:

在此StackBlitz 中,如果复选框为真,则会打开上下文菜单。但如果它是假的,它不应该打开。任何想法如何实现后者?

@Component({
    selector: 'my-app',
    template: `
        <div #target>
            Target
        </div>
        <kendo-contextmenu [target]="target" [items]="items">
        </kendo-contextmenu>

        Enable context menu <input type="checkbox" [(ngModel)]="open">
    `
})
export class AppComponent {
    public items: any[] = items;
    open = true;
}

【问题讨论】:

    标签: angular kendo-ui kendo-ui-angular2


    【解决方案1】:

    上下文菜单上没有代码告诉它不要显示。尝试添加一个 *ngIf="open" 到它。

    【讨论】:

      【解决方案2】:

      有一个popupOpen事件:

      https://www.telerik.com/kendo-angular-ui/components/menus/api/ContextMenuComponent/#toc-popupopen

      你可以在事件回调中这样取消事件:

          onPopupOpen($event: ContextMenuPopupEvent) {
              if (condition) {
                  $event.preventDefault();
                  return;
              }
          }
      

      我试图修复你的 stackblitz,但它不起作用。似乎您的 stackblitz 示例具有非常过时的角度和剑道部门。 但它在这里工作:使用 Angular 11.2.6,@progress/kendo-angular-menu": "^3.0.0"。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-12-01
        相关资源
        最近更新 更多