Kendo UI angular DialogService - Change the title bar background color

ぐ巨炮叔叔 提交于 2020-01-06 06:43:39

问题


I would like to be able to change the background-color of the resulting dialog created with the kendo UI angular's DialogService.

It's easy to adapt the content of the dialog or even override the background-color via scss but only for one fixed color while I need to chose from a few.

So I'm thinking either set the color at runtime or at least set a class on the wrapper so I can style them via scss.

Any idea?


回答1:


I worked a solution for this. It works but it is not elegant one bit.

Here's the plunker link that demonstrates the code : http://plnkr.co/edit/MGw4Wt95v9XHp9YAdoMt?p=preview

Here's the related code in the service:

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;

And the scss:

$error: #c13;
$success: #0c5;

.kendo-override {

  &.error {
    kendo-dialog-titlebar {
      background-color: $error;
    }
  }

  &.success {
    kendo-dialog-titlebar {
      background-color: $success;
    }
  }
}


来源:https://stackoverflow.com/questions/45065304/kendo-ui-angular-dialogservice-change-the-title-bar-background-color

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!