JavaScript/jQuery Drawer Options
This section describes properties that configure the Drawer UI component's contents, behavior and appearance.
See Also
- Configure a Widget: Angular | Vue | React | jQuery | AngularJS | Knockout | ASP.NET MVC 5 | ASP.NET Core
animationDuration
Specifies the duration of the drawer's opening and closing animation (in milliseconds). Applies only if animationEnabled is true.
closeOnOutsideClick
Event (jQuery or EventObject)
The raised event. It is a dxEvent or a jQuery.Event when you use jQuery.
The function passed to this property enables you to specify a custom condition for UI component closing. For instance, you can prevent closing until a user clicks a specific element on the view:
jQuery
$(function() { $("#drawerContainer").dxDrawer({ // ... closeOnOutsideClick: function(e) { return e.target === $("#someElement").get()[0]; } }); });
Angular
import { DxDrawerModule } from "devextreme-angular"; // ... export class AppComponent { // ... drawer_closeOnOutsideClick(e) { return e.target === document.getElementById("someElement"); } } @NgModule({ imports: [ // ... DxDrawerModule ], // ... })
<dx-drawer ... [closeOnOutsideClick]="drawer_closeOnOutsideClick"> </dx-drawer>
component
An alias for the template property specified in React. Accepts a custom component. Refer to Using a Custom Component for more information.
elementAttr
Specifies the global attributes to be attached to the UI component's container element.
jQuery
$(function(){ $("#drawerContainer").dxDrawer({ // ... elementAttr: { id: "elementId", class: "class-name" } }); });
Angular
<dx-drawer ... [elementAttr]="{ id: 'elementId', class: 'class-name' }"> </dx-drawer>
import { DxDrawerModule } from "devextreme-angular"; // ... export class AppComponent { // ... } @NgModule({ imports: [ // ... DxDrawerModule ], // ... })
Vue
<template> <DxDrawer ... :element-attr="drawerAttributes"> </DxDrawer> </template> <script> import DxDrawer from 'devextreme-vue/drawer'; export default { components: { DxDrawer }, data() { return { drawerAttributes: { id: 'elementId', class: 'class-name' } } } } </script>
React
import React from 'react'; import Drawer from 'devextreme-react/drawer'; class App extends React.Component { drawerAttributes = { id: 'elementId', class: 'class-name' } render() { return ( <Drawer ... elementAttr={this.drawerAttributes}> </Drawer> ); } } export default App;
height
This property accepts a value of one of the following types:
Number
The height in pixels.String
A CSS-accepted measurement of height. For example,"55px"
,"80%"
,"inherit"
.Function
A function returning either of the above. For example:JavaScriptheight: function() { return window.innerHeight / 1.5; }
maxSize
Specifies the drawer's width or height (depending on the drawer's position) in the opened state.
minSize
Specifies the drawer's width or height (depending on the drawer's position) in the closed state.
onDisposing
A function that is executed before the UI component is disposed of.
Name | Type | Description |
---|---|---|
component |
The UI component's instance. |
|
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
model |
Model data. Available only if you use Knockout. |
onInitialized
Name | Type | Description |
---|---|---|
component |
The UI component's instance. |
|
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
onOptionChanged
Name | Type | Description |
---|---|---|
model |
Model data. Available only if you use Knockout. |
|
fullName |
The path to the modified property that includes all parent properties. |
|
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
component |
The UI component's instance. |
|
name |
The modified property if it belongs to the first level. Otherwise, the first-level property it is nested into. |
|
value | any |
The modified property's new value. |
The following example shows how to subscribe to component property changes:
jQuery
$(function() { $("#drawerContainer").dxDrawer({ // ... onOptionChanged: function(e) { if(e.name === "changedProperty") { // handle the property change here } } }); });
Angular
<dx-drawer ... (onOptionChanged)="handlePropertyChange($event)"> </dx-drawer>
import { Component } from '@angular/core'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent { // ... handlePropertyChange(e) { if(e.name === "changedProperty") { // handle the property change here } } }
import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { AppComponent } from './app.component'; import { DxDrawerModule } from 'devextreme-angular'; @NgModule({ declarations: [ AppComponent ], imports: [ BrowserModule, DxDrawerModule ], providers: [ ], bootstrap: [AppComponent] }) export class AppModule { }
Vue
<template> <DxDrawer ... @option-changed="handlePropertyChange" /> </template> <script> import 'devextreme/dist/css/dx.common.css'; import 'devextreme/dist/css/dx.light.css'; import DxDrawer from 'devextreme-vue/drawer'; export default { components: { DxDrawer }, // ... methods: { handlePropertyChange: function(e) { if(e.name === "changedProperty") { // handle the property change here } } } } </script>
React
import React from 'react'; import 'devextreme/dist/css/dx.common.css'; import 'devextreme/dist/css/dx.light.css'; import Drawer from 'devextreme-react/drawer'; const handlePropertyChange = (e) => { if(e.name === "changedProperty") { // handle the property change here } } export default function App() { return ( <Drawer ... onOptionChanged={handlePropertyChange} /> ); }
openedStateMode
The following modes are available:
"overlap"
The drawer overlaps the view."shrink"
The view's width decreases to accommodate the drawer."push"
The drawer partially displaces the view.
Use the DrawerOpenedStateMode
enum to specify this property when the UI component is used as an ASP.NET MVC 5 Control or a DevExtreme-Based ASP.NET Core Control. This enum accepts the following values: Overlap
, Shrink
, and Push
.
See Also
position
Use "before" and "after" if the Drawer should be positioned differently in right-to-left and regular representations. The following table shows the dependency between the rtlEnabled value and "before" and "after" positions:
"before" | "after" | |
---|---|---|
rtlEnabled: false | left side of the view | right side of the view |
rtlEnabled: true | right side of the view | left side of the view |
Top or Bottom Position Demo Left or Right Position Demo
Use the DrawerPosition
enum to specify this property when the UI component is used as an ASP.NET MVC 5 Control or a DevExtreme-Based ASP.NET Core Control. This enum accepts the following values: Left
, Right
, Top
, Bottom
, Before
, and After
.
render
An alias for the template property specified in React. Accepts a rendering function. Refer to Using a Rendering Function for more information.
revealMode
The following modes are available:
"slide"
The drawer slides in. The drawer and its content are animated."expand"
The drawer expands from the closed position. The drawer's width is animated; its content is not.
Use the DrawerRevealMode
enum to specify this property when the UI component is used as an ASP.NET MVC 5 Control or a DevExtreme-Based ASP.NET Core Control. This enum accepts the following values: Slide
and Expand
.
See Also
rtlEnabled
When this property is set to true, the UI component text flows from right to left, and the layout of elements is reversed. To switch the entire application/site to the right-to-left representation, assign true to the rtlEnabled field of the object passed to the DevExpress.config(config) method.
DevExpress.config({ rtlEnabled: true });
See Also
- Right-to-Left Support Demo: DataGrid | Navigation Widgets | Editors
target
Specifies a CSS selector for the element in which the drawer should be rendered. Applies only when the openedStateMode is "overlap".
This property accepts one of the following values.
A CSS selector, or a jQuery selector if you use jQuery
target: '#targetElement';
A jQuery wrapper
target: $('#targetElement');
A DOM element
target: document.getElementById('#targetElement');
See Also
template
This property specifies the drawer's content. To specify the view's content, nest it inside the Drawer's markup element as shown in the code below.
jQuery
$(function() { $("#drawerContainer").dxDrawer({ template: function() { const $drawerContent = $("<div>").width(200); // ... // Specify the drawer's content here // ... return $drawerContent; } }); });
<div id="drawerContainer"> <!-- Declare the view's content here --> </div>
Angular
<dx-drawer template="drawer-content"> <div *dxTemplate="let data of 'drawer-content'" style="width:200px;"> <!-- Declare the drawer's content here --> </div> <!-- Declare the view's content here --> </dx-drawer>
Vue
<template> <DxDrawer template="drawer-content"> <template #drawer-content="{ data }" style="width:200px;"> <!-- Declare the drawer's content here --> </template> <!-- Declare the view's content here --> </DxDrawer> </template> <script> import 'devextreme/dist/css/dx.common.css'; import 'devextreme/dist/css/dx.light.css'; import DxDrawer from 'devextreme-vue/drawer'; export default { components: { DxDrawer } } </script>
React
import React from 'react'; import 'devextreme/dist/css/dx.common.css'; import 'devextreme/dist/css/dx.light.css'; import Drawer from 'devextreme-react/drawer'; function DrawerContent() { return ( <div style={{ width: 200 }}> {/* Declare the drawer's content here */} </div> ) } export default function App() { return ( <Drawer render={DrawerContent}> {/* Declare the view's content here */} </Drawer> ); }
See Also
width
This property accepts a value of one of the following types:
Number
The width in pixels.String
A CSS-accepted measurement of width. For example,"55px"
,"80%"
,"auto"
,"inherit"
.Function
A function returning either of the above. For example:JavaScriptwidth: function() { return window.innerWidth / 1.5; }