{"id":10119,"date":"2022-04-19T12:48:55","date_gmt":"2022-04-19T09:48:55","guid":{"rendered":"https:\/\/dhtmlx.com\/blog\/?p=10119"},"modified":"2025-08-29T12:05:37","modified_gmt":"2025-08-29T09:05:37","slug":"integrate-dhtmlx-suite-widgets-schedulers-lightbox","status":"publish","type":"post","link":"https:\/\/dhtmlx.com\/blog\/integrate-dhtmlx-suite-widgets-schedulers-lightbox\/","title":{"rendered":"How to Integrate DHTMLX Suite Widgets into Scheduler\u2019s Lightbox"},"content":{"rendered":"<p>When building a JavaScript scheduler, it is often needed to provide end-users with the opportunity to edit scheduled events exactly the way they like. That&#8217;s what web developers really appreciate in <a href=\"https:\/\/dhtmlx.com\/docs\/products\/dhtmlxScheduler\/\" rel=\"noopener\" target=\"_blank\">DHTMLX Scheduler<\/a> since it provides full freedom of action in this regard. It comes with the lightbox pop-up that allows changing the details of events via various controls on the fly. <\/p>\n<p>But what if you want to complement the Scheduler&#8217;s lightbox with widgets from our Suite library? The good news is that it can be done and we&#8217;ll help you out with this task. <\/p>\n<p>In this article, we provide you with step-by-step instructions on how to embed Suite widgets into the lightbox of the Scheduler component. <\/p>\n<h5>6 Steps to Add DHTMLX Calendar to Scheduler&#8217;s Lightbox<\/h5>\n<p>Any widget from the DHTMLX Suite library can be seamlessly incorporated into the editing form of our Scheduler component. The algorithm is pretty much the same for all widgets. Therefore, we take the <a href=\"https:\/\/docs.dhtmlx.com\/suite\/calendar\/\" rel=\"noopener\" target=\"_blank\">DHTMLX Calendar<\/a> as an example of how you can do it in practice. We&#8217;ll put this functionality with enabled time pickers inside the scheduler&#8217;s lightbox. It will help to conveniently specify the date and duration of events in 12- or 24-hour formats. <\/p>\n<p>Here is how the expected result should look like:<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2022\/04\/image2-1024x440.png\" alt=\"DHTMLX Scheduler - lightbox with the calendar control\" width=\"1024\" height=\"440\" class=\"aligncenter size-large wp-image-10120\" srcset=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2022\/04\/image2-1024x440.png 1024w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2022\/04\/image2-300x129.png 300w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2022\/04\/image2-768x330.png 768w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2022\/04\/image2.png 1221w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<h6>Step 1<\/h6>\n<p>First of all, it is necessary to create a new editor object in <strong>scheduler.form_blocks<\/strong>. For this purpose, you have to use the <strong>render<\/strong> method that returns HTML elements. In this method, you simply create containers, in which date pickers will be generated.<\/p>\n<div class=\"codecolorer-container javascript default codecolorer-noborder\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"javascript codecolorer\">scheduler.<span class=\"me1\">form_blocks<\/span><span class=\"br0\">&#91;<\/span><span class=\"st0\">&quot;custom_date_editor&quot;<\/span><span class=\"br0\">&#93;<\/span><span class=\"sy0\">=<\/span><span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; render<span class=\"sy0\">:<\/span><span class=\"kw1\">function<\/span><span class=\"br0\">&#40;<\/span>config<span class=\"br0\">&#41;<\/span><span class=\"br0\">&#123;<\/span> <span class=\"co1\">\/\/ config- section configuration object<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw1\">return<\/span> `<span class=\"sy0\">&lt;<\/span>div <span class=\"kw5\">class<\/span><span class=\"sy0\">=<\/span><span class=\"st0\">'custom_date_editor-wrapper'<\/span><span class=\"sy0\">&gt;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"sy0\">&lt;<\/span>div name<span class=\"sy0\">=<\/span><span class=\"st0\">&quot;start_date&quot;<\/span><span class=\"sy0\">&gt;&lt;\/<\/span>div<span class=\"sy0\">&gt;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"sy0\">&lt;<\/span>div name<span class=\"sy0\">=<\/span><span class=\"st0\">&quot;end_date&quot;<\/span><span class=\"sy0\">&gt;&lt;\/<\/span>div<span class=\"sy0\">&gt;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"sy0\">&lt;\/<\/span>div<span class=\"sy0\">&gt;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; `<span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp;<br \/>\n&nbsp; &nbsp; set_value<span class=\"sy0\">:<\/span><span class=\"kw1\">function<\/span><span class=\"br0\">&#40;<\/span>node<span class=\"sy0\">,<\/span>value<span class=\"sy0\">,<\/span>ev<span class=\"sy0\">,<\/span>config<span class=\"br0\">&#41;<\/span><span class=\"br0\">&#123;<\/span> &nbsp; &nbsp; <br \/>\n&nbsp;<br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; get_value<span class=\"sy0\">:<\/span><span class=\"kw1\">function<\/span><span class=\"br0\">&#40;<\/span>node<span class=\"sy0\">,<\/span>ev<span class=\"sy0\">,<\/span>config<span class=\"br0\">&#41;<\/span><span class=\"br0\">&#123;<\/span><br \/>\n&nbsp;<br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; focus<span class=\"sy0\">:<\/span><span class=\"kw1\">function<\/span><span class=\"br0\">&#40;<\/span>node<span class=\"br0\">&#41;<\/span><span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><span class=\"sy0\">;<\/span><\/div><\/div>\n<h6>Step 2<\/h6>\n<p>After that, you have to create public variables <strong>startDateCalendar<\/strong> and <strong>startDateCalendar<\/strong>:<\/p>\n<div class=\"codecolorer-container javascript default codecolorer-noborder\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"javascript codecolorer\">let startDateCalendar<span class=\"sy0\">;<\/span><br \/>\nlet endDateCalendar<span class=\"sy0\">;<\/span><\/div><\/div>\n<p>These variables are used for getting access to the calendar objects, where time pickers are to be placed.<\/p>\n<h6>Step 3<\/h6>\n<p>The next step is to create the <strong>initCalendars()<\/strong> function. It is called when you need to initialize calendars all over again i.e. each time when opening the lightbox. This function also deletes any old calendars, if they exist, using the <strong>destructor<\/strong> method before creating new ones. The value of the <strong>timePicker<\/strong> property should be set to true to complement date selection with the ability to choose the time for scheduled events. In the code example below, we also used the <strong>dhx_widget&#8211;bordered<\/strong> CSS class that helps to specify borders for the calendar.<\/p>\n<div class=\"codecolorer-container javascript default codecolorer-noborder\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"javascript codecolorer\"><span class=\"kw1\">function<\/span> initCalendars<span class=\"br0\">&#40;<\/span>startDateElement<span class=\"sy0\">,<\/span> endDateElement<span class=\"br0\">&#41;<\/span><span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw1\">if<\/span><span class=\"br0\">&#40;<\/span>startDateCalendar<span class=\"br0\">&#41;<\/span><span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; destroyCalendars<span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n&nbsp; &nbsp; startDateCalendar <span class=\"sy0\">=<\/span> <span class=\"kw1\">new<\/span> dhx.<span class=\"me1\">Calendar<\/span><span class=\"br0\">&#40;<\/span>startDateElement<span class=\"sy0\">,<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; timePicker<span class=\"sy0\">:<\/span> <span class=\"kw2\">true<\/span><span class=\"sy0\">,<\/span> <br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; css<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;dhx_widget--bordered&quot;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; endDateCalendar <span class=\"sy0\">=<\/span> <span class=\"kw1\">new<\/span> dhx.<span class=\"me1\">Calendar<\/span><span class=\"br0\">&#40;<\/span>endDateElement<span class=\"sy0\">,<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; timePicker<span class=\"sy0\">:<\/span> <span class=\"kw2\">true<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; css<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;dhx_widget--bordered&quot;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><br \/>\n&nbsp;<br \/>\n<span class=\"kw1\">function<\/span> destroyCalendars<span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw1\">if<\/span><span class=\"br0\">&#40;<\/span>startDateCalendar<span class=\"br0\">&#41;<\/span><span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; startDateCalendar.<span class=\"me1\">destructor<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; endDateCalendar.<span class=\"me1\">destructor<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; startDateCalendar <span class=\"sy0\">=<\/span> <span class=\"kw2\">null<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; endDateCalendar <span class=\"sy0\">=<\/span> <span class=\"kw2\">null<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><\/div><\/div>\n<h6>Step 4<\/h6>\n<p>Now it is time to consider the <strong>set_value<\/strong> function in the lightbox control object. This method is called whenever the control receives new values. It happens when the lightbox is opened and when the control receives a new value via <a href=\"https:\/\/docs.dhtmlx.com\/scheduler\/api__scheduler_formsection.html\" rel=\"noopener\" target=\"_blank\">API<\/a>.<\/p>\n<p>That is where you have to initialize the calendars and populate their values:<\/p>\n<div class=\"codecolorer-container javascript default codecolorer-noborder\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"javascript codecolorer\">set_value<span class=\"sy0\">:<\/span><span class=\"kw1\">function<\/span><span class=\"br0\">&#40;<\/span>node<span class=\"sy0\">,<\/span>value<span class=\"sy0\">,<\/span>ev<span class=\"sy0\">,<\/span>config<span class=\"br0\">&#41;<\/span><span class=\"br0\">&#123;<\/span> &nbsp; &nbsp; <br \/>\n&nbsp; &nbsp; initCalendars<span class=\"br0\">&#40;<\/span>node.<span class=\"me1\">querySelector<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;[name='start_date']&quot;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">,<\/span> node.<span class=\"me1\">querySelector<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;[name='end_date']&quot;<\/span><span class=\"br0\">&#41;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp;<br \/>\n&nbsp; &nbsp; startDateCalendar.<span class=\"me1\">setValue<\/span><span class=\"br0\">&#40;<\/span><span class=\"kw1\">new<\/span> <span class=\"kw4\">Date<\/span><span class=\"br0\">&#40;<\/span>ev.<span class=\"me1\">start_date<\/span><span class=\"br0\">&#41;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; endDateCalendar.<span class=\"me1\">setValue<\/span><span class=\"br0\">&#40;<\/span><span class=\"kw1\">new<\/span> <span class=\"kw4\">Date<\/span><span class=\"br0\">&#40;<\/span>ev.<span class=\"me1\">end_date<\/span><span class=\"br0\">&#41;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><span class=\"sy0\">,<\/span><\/div><\/div>\n<h6>Step 5<\/h6>\n<p>To enable the control to save the values in the event, it&#8217;s necessary to return these values from the <strong>get_value<\/strong> function.<\/p>\n<p>In our case, the function will look like this:<\/p>\n<div class=\"codecolorer-container javascript default codecolorer-noborder\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"javascript codecolorer\">get_value<span class=\"sy0\">:<\/span><span class=\"kw1\">function<\/span><span class=\"br0\">&#40;<\/span>node<span class=\"sy0\">,<\/span>ev<span class=\"sy0\">,<\/span>config<span class=\"br0\">&#41;<\/span><span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw1\">const<\/span> start_date <span class=\"sy0\">=<\/span> startDateCalendar.<span class=\"me1\">getValue<\/span><span class=\"br0\">&#40;<\/span><span class=\"kw2\">true<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw1\">const<\/span> end_date <span class=\"sy0\">=<\/span> endDateCalendar.<span class=\"me1\">getValue<\/span><span class=\"br0\">&#40;<\/span><span class=\"kw2\">true<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; ev.<span class=\"me1\">start_date<\/span> <span class=\"sy0\">=<\/span> start_date<span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; ev.<span class=\"me1\">end_date<\/span> <span class=\"sy0\">=<\/span> end_date<span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw1\">return<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; start_date<span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; end_date<br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><span class=\"sy0\">;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><span class=\"sy0\">,<\/span><\/div><\/div>\n<p>It is important to clarify two important things that you are doing here:<\/p>\n<ol>\n<li>You modify the event passed via arguments and assign new date values to this object directly. This is a common approach for controls that are mapped to several different properties of the event.<\/li>\n<li>You return the date picker values from the function as the <strong>{ start_date, end_date }<\/strong> object. It allows the <a href=\"https:\/\/docs.dhtmlx.com\/scheduler\/api__scheduler_formsection.html\" rel=\"noopener\" target=\"_blank\">scheduler.formSection(name).getValue()<\/a> method to get access to the control values.<\/li>\n<\/ol>\n<p>When implementing a simpler control that is mapped to a single property of the event object, you won&#8217;t need to modify the event object and only need to return the value from the method. The return value will be assigned to the <a href=\"https:\/\/docs.dhtmlx.com\/scheduler\/api__scheduler_lightbox_config.html#meaningofmaptoauto\" rel=\"noopener\" target=\"_blank\">corresponding property<\/a> of the event object automatically. You can check the <a href=\"https:\/\/snippet.dhtmlx.com\/7jqej8jb\" rel=\"noopener\" target=\"_blank\">colorpicker example<\/a> to see how it works in practice.<\/p>\n<h6>Step 6<\/h6>\n<p>Finally, it is required to destroy calendars when they are no longer needed. It is usually done using the <a href=\"https:\/\/docs.dhtmlx.com\/scheduler\/api__scheduler_onafterlightbox_event.html\" rel=\"noopener\" target=\"_blank\"><strong>onAfterLightbox<\/strong><\/a> event of DHTMLX Scheduler:<\/p>\n<div class=\"codecolorer-container javascript default codecolorer-noborder\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"javascript codecolorer\">scheduler.<span class=\"me1\">attachEvent<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;onAfterLightbox&quot;<\/span><span class=\"sy0\">,<\/span> destroyCalendars<span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><\/div><\/div>\n<p>In this <a href=\"https:\/\/snippet.dhtmlx.com\/n9jyb9o4?mode=wide\" rel=\"noopener\" target=\"_blank\">sample<\/a>, you can see the event calendar with the embedded time picker functionality and play around with it.<\/p>\n<h5>Final Words<\/h5>\n<p>Following the steps provided in this guide, you can quickly enrich your JavaScript scheduler with numerous useful editing options using any widget from DHTMLX Suite. Here are also examples of schedulers with the <a href=\"https:\/\/snippet.dhtmlx.com\/45jdudjv\" rel=\"noopener\" target=\"_blank\">DHTMLX Slider<\/a> and <a href=\"https:\/\/snippet.dhtmlx.com\/wyi2gep5\" rel=\"noopener\" target=\"_blank\">DHTMLX Color Picker<\/a> embedded into the editing form. If you want to enrich the Scheduler&#8217;s lightbox with your own controls, this <a href=\"https:\/\/docs.dhtmlx.com\/scheduler\/custom_lightbox_editor.html\" rel=\"noopener\" target=\"_blank\">guide<\/a> will help you to do it right. <\/p>\n<p>For those who are new to our products and want to try them in action, make use of <a href=\"https:\/\/dhtmlx.com\/docs\/download\/\" rel=\"noopener\" target=\"_blank\">free 30-day trial versions<\/a>. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>When building a JavaScript scheduler, it is often needed to provide end-users with the opportunity to edit scheduled events exactly the way they like. That&#8217;s what web developers really &#8230;<\/p>\n","protected":false},"author":101014,"featured_media":10121,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[71],"tags":[33,15,10],"class_list":["post-10119","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-all-posts","tag-dhtmlxscheduler","tag-dhtmlxsuite"],"_links":{"self":[{"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts\/10119","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/users\/101014"}],"replies":[{"embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/comments?post=10119"}],"version-history":[{"count":11,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts\/10119\/revisions"}],"predecessor-version":[{"id":14347,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts\/10119\/revisions\/14347"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/media\/10121"}],"wp:attachment":[{"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/media?parent=10119"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/categories?post=10119"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/tags?post=10119"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}