{"id":2523,"date":"2014-10-28T19:42:24","date_gmt":"2014-10-28T15:42:24","guid":{"rendered":"http:\/\/www.dhtmlx.com\/blog\/?p=2523"},"modified":"2023-05-05T13:56:50","modified_gmt":"2023-05-05T10:56:50","slug":"mini-calendar-in-dhtmlxscheduler","status":"publish","type":"post","link":"https:\/\/dhtmlx.com\/blog\/mini-calendar-in-dhtmlxscheduler\/","title":{"rendered":"DHTMLX Little-Known Features: Mini Calendar in dhtmlxScheduler"},"content":{"rendered":"<p><a href=\"https:\/\/docs.dhtmlx.com\/scheduler\/minicalendar.html\" target=\"_blank\">Mini calendar<\/a> in our <a href=\"https:\/\/dhtmlx.com\/docs\/products\/dhtmlxScheduler\/\" target=\"_blank\">JavaScript Scheduler<\/a> can&#8217;t be named &#8220;little-known&#8221; feature and it&#8217;s some kind of &#8220;must have&#8221; in each appointment calendar. But in this article we&#8217;ll tell you about all the ways how and where you can place this small but very useful thing.<\/p>\n<p>So, let&#8217;s start. First of all, we need to add the <strong>ext\/dhtmlxscheduler_minical.js<\/strong> extension file on the page.<\/p>\n<div class=\"codecolorer-container javascript default codecolorer-noborder\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"javascript codecolorer\"><span class=\"sy0\">&lt;<\/span>script src<span class=\"sy0\">=<\/span><span class=\"st0\">'\/ext\/dhtmlxscheduler_minical.js'<\/span> type<span class=\"sy0\">=<\/span><span class=\"st0\">&quot;text\/javascript&quot;<\/span><span class=\"sy0\">&gt;&lt;\/<\/span>script<span class=\"sy0\">&gt;<\/span><\/div><\/div>\n<p>Then we need to decide where we would like to place our mini calendar. Pick up the variant that suits you and let&#8217;s add it to the scheduler (you can add the mini calendar at each of them).<\/p>\n<p>1. A mini calendar can be used for a quick navigation between dates of scheduler and be  placed <strong>in the header<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2014\/10\/calendar-in-header.png\" alt=\"calendar-in-the-header\" width=\"592\" height=\"409\" class=\"aligncenter size-full wp-image-2524\" srcset=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2014\/10\/calendar-in-header.png 592w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2014\/10\/calendar-in-header-300x207.png 300w\" sizes=\"auto, (max-width: 592px) 100vw, 592px\" \/><br \/>\n<!--more--><br \/>\nFor this:<\/p>\n<ul>\n<li>Include the needed extension file as it was mentioned above;<\/li>\n<li>Specify the container for the mini calendar and add it to the scheduler markup:<\/li>\n<p><\/p>\n<div class=\"codecolorer-container javascript default codecolorer-noborder\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"javascript codecolorer\"><span class=\"sy0\">&lt;<\/span>div <span class=\"kw5\">class<\/span><span class=\"sy0\">=<\/span><span class=\"st0\">&quot;dhx_cal_navline&quot;<\/span><span class=\"sy0\">&gt;<\/span><br \/>\n&nbsp; &nbsp; ...<br \/>\n&nbsp; &nbsp; <span class=\"sy0\">&lt;<\/span>div <span class=\"kw5\">class<\/span><span class=\"sy0\">=<\/span><span class=\"st0\">&quot;dhx_cal_date&quot;<\/span><span class=\"sy0\">&gt;&lt;\/<\/span>div<span class=\"sy0\">&gt;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"sy0\">&lt;<\/span>div <span class=\"kw5\">class<\/span><span class=\"sy0\">=<\/span><span class=\"st0\">&quot;dhx_minical_icon&quot;<\/span> id<span class=\"sy0\">=<\/span><span class=\"st0\">&quot;dhx_minical_icon&quot;<\/span> <br \/>\n&nbsp; &nbsp; onclick<span class=\"sy0\">=<\/span><span class=\"st0\">&quot;show_minical()&quot;<\/span><span class=\"sy0\">&gt;&amp;<\/span>nbsp<span class=\"sy0\">;&lt;\/<\/span>div<span class=\"sy0\">&gt;<\/span><br \/>\n<span class=\"sy0\">&lt;\/<\/span>div<span class=\"sy0\">&gt;<\/span><\/div><\/div>\n<li>Provide the logic that should initialize (the <a href=\"https:\/\/docs.dhtmlx.com\/scheduler\/api__scheduler_rendercalendar.html\" target=\"_blank\">renderCalendar<\/a> method) and destroy (the <a href=\"https:\/\/docs.dhtmlx.com\/scheduler\/api__scheduler_destroycalendar.html\" target=\"_blank\">destroyCalendar <\/a>method) the mini calendar:<\/li>\n<\/ul>\n<p><\/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> show_minical<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>scheduler.<span class=\"me1\">isCalendarVisible<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"br0\">&#41;<\/span><span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; scheduler.<span class=\"me1\">destroyCalendar<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span> <span class=\"kw1\">else<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; scheduler.<span class=\"me1\">renderCalendar<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; position<span class=\"sy0\">:<\/span><span class=\"st0\">&quot;dhx_minical_icon&quot;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; date<span class=\"sy0\">:<\/span>scheduler._date<span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; navigation<span class=\"sy0\">:<\/span><span class=\"kw2\">true<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; handler<span class=\"sy0\">:<\/span><span class=\"kw1\">function<\/span><span class=\"br0\">&#40;<\/span>date<span class=\"sy0\">,<\/span>calendar<span class=\"br0\">&#41;<\/span><span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scheduler.<span class=\"me1\">setCurrentView<\/span><span class=\"br0\">&#40;<\/span>date<span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scheduler.<span class=\"me1\">destroyCalendar<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><\/div><\/div>\n<p>Check what you should achieve in the <a href=\"https:\/\/docs.dhtmlx.com\/scheduler\/samples\/05_calendar\/01_select.html\" target=\"_blank\">demo<\/a>.<\/p>\n<p>2. A mini calendar can be used as a user-friendly <strong>date picker for the lightbox<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dhtmlx.com\/blog\/wp-content\/uploads\/2014\/10\/in-the-lightbox1.png\" alt=\"calendar-in-the-lightbox\" width=\"595\" height=\"501\" class=\"aligncenter size-full wp-image-2529\" srcset=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2014\/10\/in-the-lightbox1.png 595w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2014\/10\/in-the-lightbox1-300x252.png 300w\" sizes=\"auto, (max-width: 595px) 100vw, 595px\" \/><\/p>\n<p>For this:<\/p>\n<ul>\n<li>Include the needed extension file as it was mentioned above;<\/li>\n<li>Set the type of the time section to calendar_time (instead of time):<\/li>\n<\/ul>\n<p><\/p>\n<div class=\"codecolorer-container javascript default codecolorer-noborder\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"javascript codecolorer\"><span class=\"co1\">\/\/default lightbox definition<\/span><br \/>\nscheduler.<span class=\"me1\">config<\/span>.<span class=\"me1\">lightbox<\/span>.<span class=\"me1\">sections<\/span><span class=\"sy0\">=<\/span><span class=\"br0\">&#91;<\/span><br \/>\n&nbsp; <span class=\"br0\">&#123;<\/span>name<span class=\"sy0\">:<\/span><span class=\"st0\">&quot;description&quot;<\/span><span class=\"sy0\">,<\/span> height<span class=\"sy0\">:<\/span><span class=\"nu0\">200<\/span><span class=\"sy0\">,<\/span> map_to<span class=\"sy0\">:<\/span><span class=\"st0\">&quot;text&quot;<\/span><span class=\"sy0\">,<\/span> type<span class=\"sy0\">:<\/span><span class=\"st0\">&quot;textarea&quot;<\/span><span class=\"sy0\">,<\/span> focus<span class=\"sy0\">:<\/span><span class=\"kw2\">true<\/span><span class=\"br0\">&#125;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; <span class=\"br0\">&#123;<\/span>name<span class=\"sy0\">:<\/span><span class=\"st0\">&quot;time&quot;<\/span><span class=\"sy0\">,<\/span> height<span class=\"sy0\">:<\/span><span class=\"nu0\">72<\/span><span class=\"sy0\">,<\/span> type<span class=\"sy0\">:<\/span><span class=\"st0\">&quot;time&quot;<\/span><span class=\"sy0\">,<\/span> map_to<span class=\"sy0\">:<\/span><span class=\"st0\">&quot;auto&quot;<\/span><span class=\"br0\">&#125;<\/span><br \/>\n<span class=\"br0\">&#93;<\/span><span class=\"sy0\">;<\/span><br \/>\n<span class=\"co1\">\/\/change type:&quot;time&quot; -&gt; type:&quot;calendar_time&quot;<\/span><br \/>\nscheduler.<span class=\"me1\">config<\/span>.<span class=\"me1\">lightbox<\/span>.<span class=\"me1\">sections<\/span> <span class=\"sy0\">=<\/span> <span class=\"br0\">&#91;<\/span><br \/>\n&nbsp; <span class=\"br0\">&#123;<\/span>name<span class=\"sy0\">:<\/span><span class=\"st0\">&quot;description&quot;<\/span><span class=\"sy0\">,<\/span> height<span class=\"sy0\">:<\/span><span class=\"nu0\">200<\/span><span class=\"sy0\">,<\/span> map_to<span class=\"sy0\">:<\/span><span class=\"st0\">&quot;text&quot;<\/span><span class=\"sy0\">,<\/span> type<span class=\"sy0\">:<\/span><span class=\"st0\">&quot;textarea&quot;<\/span><span class=\"sy0\">,<\/span> focus<span class=\"sy0\">:<\/span><span class=\"kw2\">true<\/span><span class=\"br0\">&#125;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; <span class=\"br0\">&#123;<\/span>name<span class=\"sy0\">:<\/span><span class=\"st0\">&quot;time&quot;<\/span><span class=\"sy0\">,<\/span> height<span class=\"sy0\">:<\/span><span class=\"nu0\">72<\/span><span class=\"sy0\">,<\/span> type<span class=\"sy0\">:<\/span><span class=\"st0\">&quot;calendar_time&quot;<\/span><span class=\"sy0\">,<\/span> map_to<span class=\"sy0\">:<\/span><span class=\"st0\">&quot;auto&quot;<\/span> <span class=\"br0\">&#125;<\/span><br \/>\n<span class=\"br0\">&#93;<\/span><span class=\"sy0\">;<\/span><\/div><\/div>\n<p>Check the <a href=\"https:\/\/docs.dhtmlx.com\/scheduler\/samples\/05_calendar\/03_in_form.html\" target=\"_blank\">demo<\/a> to see the results.<\/p>\n<p>Generally, the mini calendar can be considered as a separate component and used apart from the scheduler; you may bind a date picker to any input on the page. <\/p>\n<p>This means that you can add the mini calendar to <a href=\"https:\/\/docs.dhtmlx.com\/scheduler\/minicalendar.html#minicalendarinanhtmlcontaineroutsidethescheduler\" target=\"_blank\">any place outside the scheduler<\/a>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2014\/10\/outside-the-scheduler.png\" alt=\"calendar-outside-the-scheduler\" width=\"566\" height=\"347\" class=\"aligncenter size-full wp-image-2526\" srcset=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2014\/10\/outside-the-scheduler.png 566w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2014\/10\/outside-the-scheduler-300x183.png 300w\" sizes=\"auto, (max-width: 566px) 100vw, 566px\" \/><\/p>\n<p>Get learn how you can <a href=\"https:\/\/docs.dhtmlx.com\/scheduler\/minicalendar.html#customizingtheminicalendar\" target=\"_blank\">customize the mini calendar<\/a> and also find out all the <a href=\"https:\/\/docs.dhtmlx.com\/scheduler\/minicalendar.html#relatedmethods\" target=\"_blank\">related methods<\/a>.<\/p>\n<p>Hope this article was useful for you. Next week we\u2019ll continue to share the most interesting features providing by DHTMLX components.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Mini calendar in our JavaScript Scheduler can&#8217;t be named &#8220;little-known&#8221; feature and it&#8217;s some kind of &#8220;must have&#8221; in each appointment calendar. But in this article we&#8217;ll tell you &#8230;<\/p>\n","protected":false},"author":2,"featured_media":3317,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,71,1],"tags":[33,43,14,15],"class_list":["post-2523","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-posts-for-codeproject-com","category-tutorials","category-uncategorized","tag-all-posts","tag-dhtmlx-tips","tag-tips","tag-dhtmlxscheduler"],"_links":{"self":[{"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts\/2523","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\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/comments?post=2523"}],"version-history":[{"count":1,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts\/2523\/revisions"}],"predecessor-version":[{"id":10686,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts\/2523\/revisions\/10686"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/media\/3317"}],"wp:attachment":[{"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/media?parent=2523"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/categories?post=2523"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/tags?post=2523"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}