|
| 1 | +--- |
| 2 | +title: Changing MinorTickCount at Runtime in Kendo jQuery Scheduler |
| 3 | +description: Learn how to update the `minorTickCount` property dynamically using the `.view()` method in Scheduler. |
| 4 | +type: how-to |
| 5 | +page_title: Modify minorTickCount in Kendo Scheduler |
| 6 | +slug: scheduler-refresh-minortickcount |
| 7 | +tags: scheduler, view, minorTickCount, setOptions, kendo ui |
| 8 | +res_type: kb |
| 9 | +ticketid: 1689609 |
| 10 | +--- |
| 11 | + |
| 12 | +## Environment |
| 13 | +<table> |
| 14 | +<tbody> |
| 15 | +<tr> |
| 16 | +<td>Product</td> |
| 17 | +<td> |
| 18 | +Scheduler for Progress® Kendo UI® |
| 19 | +</td> |
| 20 | +</tr> |
| 21 | +<tr> |
| 22 | +<td>Version</td> |
| 23 | +<td>2025.2.520</td> |
| 24 | +</tr> |
| 25 | +</tbody> |
| 26 | +</table> |
| 27 | + |
| 28 | +## Description |
| 29 | + |
| 30 | +When changing the `minorTickCount` property of the Scheduler using the `setOptions` method and attempting to reload the view with `scheduler.view("day")`, the Scheduler may not redraw correctly to reflect the updated `minorTickCount`. This issue can occur because the changes are not applied directly to the current view configuration. |
| 31 | + |
| 32 | +This knowledge base article also answers the following questions: |
| 33 | +- How to refresh Kendo UI Scheduler after modifying minorTickCount? |
| 34 | +- Why is the Scheduler view not updating after changing minorTickCount? |
| 35 | +- How can I apply minorTickCount changes to the current Scheduler view? |
| 36 | + |
| 37 | +## Solution |
| 38 | + |
| 39 | +To ensure the Scheduler view updates correctly after changing the `minorTickCount`, use the following approach: |
| 40 | + |
| 41 | +### Applying `minorTickCount` to a Specific View |
| 42 | + |
| 43 | +If the `minorTickCount` is set per view, update the view configuration and refresh the view using the `.view()` method: |
| 44 | + |
| 45 | +```javascript |
| 46 | +$("#scheduler").data("kendoScheduler").views["day"].minorTickCount = 5; |
| 47 | +$("#scheduler").data("kendoScheduler").view("day"); |
| 48 | +``` |
| 49 | + |
| 50 | +### Applying `minorTickCount` to the Current View |
| 51 | + |
| 52 | +To apply the change to the current view dynamically, retrieve the current view name and refresh it: |
| 53 | + |
| 54 | +```javascript |
| 55 | +$("#scheduler").data("kendoScheduler").views[scheduler.viewName()].minorTickCount = 5; |
| 56 | +$("#scheduler").data("kendoScheduler").view(scheduler.viewName()); |
| 57 | +``` |
| 58 | + |
| 59 | +### Example |
| 60 | + |
| 61 | +```dojo |
| 62 | + <script src="../content/shared/js/schedulerTasks.js"></script> |
| 63 | +
|
| 64 | + <div id="example"> |
| 65 | + <div id="scheduler"></div> |
| 66 | + <button id="updateMinorTickCountButton">Update minor tick count</button> |
| 67 | + </div> |
| 68 | +
|
| 69 | + <script id="event-template" type="text/x-kendo-template"> |
| 70 | + <div class="template-container"> |
| 71 | + # if (image != "") { # |
| 72 | + <img alt="Kendo UI for jQuery Scheduler #:title #" src="#= image #" style="height:25px; width: 25px;"> |
| 73 | + # } # |
| 74 | + <h3 class="template-title-#= resources[0].value #">#: title #</h3> |
| 75 | + </div> |
| 76 | + </script> |
| 77 | +
|
| 78 | + <script> |
| 79 | + var sampleDataNextID = schedulerTasks.length + 1; |
| 80 | +
|
| 81 | + function getIndexById(id) { |
| 82 | + var idx, |
| 83 | + l = schedulerTasks.length; |
| 84 | +
|
| 85 | + for (var j = 0; j < l; j++) { |
| 86 | + if (schedulerTasks[j].id == id) { |
| 87 | + return j; |
| 88 | + } |
| 89 | + } |
| 90 | + return null; |
| 91 | + } |
| 92 | +
|
| 93 | + $(function () { |
| 94 | + var dataSource = new kendo.data.SchedulerDataSource({ |
| 95 | + transport: { |
| 96 | + read: function (e) { |
| 97 | + e.success(schedulerTasks); |
| 98 | + }, |
| 99 | + create: function (e) { |
| 100 | + e.data.id = sampleDataNextID++; |
| 101 | + schedulerTasks.push(e.data); |
| 102 | + e.success(e.data); |
| 103 | + }, |
| 104 | + update: function (e) { |
| 105 | + schedulerTasks[getIndexById(e.data.id)] = e.data; |
| 106 | + e.success(); |
| 107 | + }, |
| 108 | + destroy: function (e) { |
| 109 | + schedulerTasks.splice(getIndexById(e.data.id), 1); |
| 110 | + e.success(); |
| 111 | + }, |
| 112 | + }, |
| 113 | + error: function (e) { |
| 114 | + alert("Status: " + e.status + "; Error message: " + e.errorThrown); |
| 115 | + }, |
| 116 | + batch: false, |
| 117 | + schema: { |
| 118 | + model: { |
| 119 | + id: "id", |
| 120 | + fields: { |
| 121 | + id: { type: "number" }, |
| 122 | + title: { |
| 123 | + field: "title", |
| 124 | + defaultValue: "No title", |
| 125 | + validation: { required: true }, |
| 126 | + }, |
| 127 | + start: { type: "date", field: "start" }, |
| 128 | + end: { type: "date", field: "end" }, |
| 129 | + description: { field: "description" }, |
| 130 | + recurrenceRule: { from: "recurrenceRule" }, |
| 131 | + recurrenceException: { from: "recurrenceException" }, |
| 132 | + attendee: { field: "attendee", defaultValue: 1 }, |
| 133 | + isAllDay: { type: "boolean", field: "isAllDay" }, |
| 134 | + image: { from: "image", defaultValue: "" }, |
| 135 | + }, |
| 136 | + }, |
| 137 | + }, |
| 138 | + }); |
| 139 | +
|
| 140 | + $("#scheduler").kendoScheduler({ |
| 141 | + date: new Date("2020/10/4"), |
| 142 | + startTime: new Date("2020/10/4 7:00"), |
| 143 | + endTime: new Date("2020/10/4 20:00"), |
| 144 | + height: 600, |
| 145 | + views: [ |
| 146 | + { type: "day", minorTickCount: 2 }, |
| 147 | + { type: "week", selected: true }, |
| 148 | + "workWeek", |
| 149 | + "month", |
| 150 | + "agenda", |
| 151 | + ], |
| 152 | + timezone: "Etc/UTC", |
| 153 | + eventTemplate: $("#event-template").html(), |
| 154 | + dataSource: dataSource, |
| 155 | + resources: [ |
| 156 | + { |
| 157 | + field: "attendee", |
| 158 | + dataSource: [ |
| 159 | + { text: "Jason", value: 1, color: "#eaf8ff" }, |
| 160 | + { text: "Maddie", value: 2, color: "#fdfdf4" }, |
| 161 | + ], |
| 162 | + }, |
| 163 | + ], |
| 164 | + }); |
| 165 | +
|
| 166 | + $("#updateMinorTickCountButton").click(function () { |
| 167 | + const Scheduler = $("#scheduler").data("kendoScheduler"); |
| 168 | +
|
| 169 | + alert( |
| 170 | + "current minor tick count " + |
| 171 | + Scheduler.options.views[0].minorTickCount, |
| 172 | + ); |
| 173 | +
|
| 174 | + Scheduler.setOptions({ |
| 175 | + views: [ |
| 176 | + { type: "day", minorTickCount: 5 }, |
| 177 | + { type: "week", selected: true }, |
| 178 | + "workWeek", |
| 179 | + "month", |
| 180 | + "agenda", |
| 181 | + ], |
| 182 | + }); |
| 183 | +
|
| 184 | + alert( |
| 185 | + "current minor tick count " + |
| 186 | + Scheduler.options.views[0].minorTickCount, |
| 187 | + ); |
| 188 | +
|
| 189 | + $("#scheduler").data("kendoScheduler").views["day"].minorTickCount = |
| 190 | + 5; |
| 191 | + $("#scheduler").data("kendoScheduler").view(Scheduler.viewName()); |
| 192 | + }); |
| 193 | + }); |
| 194 | + </script> |
| 195 | +
|
| 196 | + <style> |
| 197 | + .template-container { |
| 198 | + margin-top: -8px; |
| 199 | + } |
| 200 | +
|
| 201 | + .template-container img { |
| 202 | + float: left; |
| 203 | + margin: 0 4px; |
| 204 | + margin-right: 10px; |
| 205 | + } |
| 206 | +
|
| 207 | + .template-container h3 { |
| 208 | + padding: 0 4px 4px; |
| 209 | + font-size: 12px; |
| 210 | + font-weight: 400; |
| 211 | + margin-right: 14px; |
| 212 | + } |
| 213 | +
|
| 214 | + .template-title-1 { |
| 215 | + color: #65ccff; |
| 216 | + } |
| 217 | +
|
| 218 | + .template-title-2 { |
| 219 | + color: #d0d03b; |
| 220 | + } |
| 221 | +
|
| 222 | + .k-event .k-i-reload, |
| 223 | + .k-event .k-i-non-recurrence { |
| 224 | + display: none; |
| 225 | + } |
| 226 | + </style> |
| 227 | +``` |
| 228 | + |
| 229 | +## See Also |
| 230 | + |
| 231 | +- [Scheduler Documentation](https://docs.telerik.com/kendo-ui/api/javascript/ui/scheduler) |
| 232 | +- [Scheduler View Configuration](https://docs.telerik.com/kendo-ui/api/javascript/ui/scheduler/configuration/views) |
| 233 | +- [Scheduler minorTickCount API](https://docs.telerik.com/kendo-ui/api/javascript/ui/scheduler#configuration-views.minorTickCount) |
0 commit comments