Skip to main content

Customization

This article describes how to change icons, manage controls in the header and footer, and apply custom styles to a window.

Default and custom icons​

DHTMLX Window uses default icons based on Material Design. However, you can use another icon font pack. To do this, include the icon font on the page and assign its icons to controls in the header or footer.

For example, to use the Font Awesome icon pack, include a link to its CDN after the source files of DHTMLX Window:

<script type="text/javascript" src="../../codebase/window.js"></script>
<link rel="stylesheet" href="../../codebase/window.css">

<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css"
integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU"
crossOrigin="anonymous">

Then set an icon name as the value of the icon property in the object with the control parameters for the header or footer. See details below.

Related sample: Window. Custom icons

Controls and operations​

The header and footer of a window can contain any Toolbar controls. You can manage them in the same way as Toolbar controls: add new controls, update control settings such as labels and icons, and delete controls you don't need.

Add controls​

You can add more controls to the header or footer at runtime.

Window with custom thumb up and thumb down buttons added to the footer in DHTMLX Suite

Use the add() method of TreeCollection. The method takes the following parameters:

config(object) the configuration object of the added control
index(number) optional, the position to add a control at
parent(string) optional, the id of a parent control (for the menuItem control type)

dhxWindow.header.data.add({icon: "mdi mdi-fullscreen", id: "fullscreen"}, 2);
dhxWindow.footer.data.add({type: "spacer"});
dhxWindow.footer.data.add({icon: "mdi mdi-thumb-up", id: "like"});
dhxWindow.footer.data.add({icon: "mdi mdi-thumb-down", id: "dislike"})

Related sample: Window. Custom buttons

Update controls​

Use the update() method of TreeCollection to change the icon or other settings of a control in the header or footer. The method takes two parameters:

  • The id of the control
  • An object with the new configuration of the control
dhxWindow.header.data.update("close", {
// using FA icon for the Close button
icon: "fas fa-times"
});

Related sample: Window. Custom icons

Delete controls​

Use the remove() method of TreeCollection to remove a control from the header or footer. Pass the id of the control to the method:

dhxWindow.footer.data.remove("accept");

Use custom CSS classes​

You can change the look and feel of a window.

Custom styled Window with fullscreen and Close header buttons and footer icons in DHTMLX Suite

Related sample: Window. Styling (custom CSS)

Follow these steps:

  • Add one or more CSS classes with the settings you need. Place them in the <style> section of your HTML page or in a separate stylesheet. If you use a stylesheet, include it on the page:
<style>
.my-first-class {
/*some styles*/
}

.my-second-class {
/*some styles*/
}
</style>
  • Specify the name of the class you created (or several class names separated by spaces) as the value of the css property in the Window configuration:
const dhxWindow = new dhx.Window({
title: "Window",
css:"my-first-class my-second-class"
});
dhxWindow.show();

For example:

<style>
.custom {
--dhx-background-primary: #efefef;
}
</style>

<script>
const dhxWindow = new dhx.Window({
height: 400,
width: 400,
title: "window",
css: "custom",
html,
});

dhxWindow.show();
</script>