代码之家  ›  专栏  ›  技术社区  ›  CodeMan03

KendoUI对话框服务更改标题颜色

  •  0
  • CodeMan03  · 技术社区  · 7 年前

    使用剑道对话服务时,是否需要更改对话窗口的颜色?

    我尝试使用剑道对话框作为模板,但它没有显示动作按钮。

    <kendo-dialog title="{{title}}" (close)="Cancel()" [ngClass]="yellow">
    </kendo-dialog>
    
    1 回复  |  直到 7 年前
        1
  •  1
  •   Jahrenski    7 年前

    不久前,我问了自己同样的问题,并在这篇文章中找到了一个解决方案: Kendo UI angular DialogService - Change the title bar background color

    我为此制定了一个解决方案。它可以工作,但一点也不优雅。

    下面是演示代码的plunker链接: http://plnkr.co/edit/MGw4Wt95v9XHp9YAdoMt?p=preview

    const dialog: DialogRef = this.dialogService.open({
      actions: message.actions,
      content: MessageComponent,
      title:   message.title
    });
    
    const messageComponent = dialog.content.instance;
    messageComponent.message = message;
    
    //I get the dialog element and use jQuery to add classes to override styles.
    //Let's say I had the error class as well.
    const element = dialog.dialog.location.nativeElement;
    $( element ).addClass( 'kendo-override ' + message.classes );
    
    return dialog.result;
    

    $error: #c13;
    $success: #0c5;
    
    .kendo-override {
    
      &.error {
        kendo-dialog-titlebar {
          background-color: $error;
        }
      }
    
      &.success {
        kendo-dialog-titlebar {
          background-color: $success;
        }
      }
    }