Scroll to current Date in TimelineMonth view

0 Answers 179 Views
Scheduler
Stefan
Top achievements
Rank 1
Iron
Stefan asked on 08 Jun 2021, 01:48 PM

Hi,

Is there any examples where scheduler is automatically scrolled to current date, but for scheduler created in ASP.NET Core?

This is exactly what I need, but I can't make it work in my ASP.NET Core project: https://www.telerik.com/forums/scheduler-timelinemonth-current-day-visible

My rows.length are always 0, so is my contentDiv.length, when I checked it. 

var scheduler = $("#scheduler").getKendoScheduler();
var contentDiv = scheduler.element.find("div.k-scheduler-content");
var rows = contentDiv.find("tr td");

for (var i = 0; i < rows.length; i++) {
            var slot = scheduler.slotByElement(rows[i]);

            var slotTime = kendo.toString(slot.startDate, "d");
            var targetTime = kendo.toString(time, "d");

            if (targetTime === slotTime) {
                contentDiv.scrollLeft($(rows[i]).offset().left + contentDiv.scrollLeft() - contentDiv.position().left);
            }
        };
Stefan
Top achievements
Rank 1
Iron
commented on 09 Jun 2021, 12:38 PM

I managed to fix it. The problem was that I invoked my function from (document).ready. I guess that it was called before content was created. I moved my funcion call to DataBound Event and everything works perfectly.
Tsvetomir
Telerik team
commented on 11 Jun 2021, 07:35 AM

Hi, Stefan. Thank you for sharing your solution for the ASP.NET Core framework with the community. Indeed, the DataBound event is suitable as it is invoked when the content has been rendered and the data is bound. 

Please note that this event is invoked every time server operations with data are initiated. Hence, potentially you could be scrolling the content every time the user interacts with the widget. 

If applicable or needed, you could unbind the event by using the unbind("dataBound") method.

No answers yet. Maybe you can help?

Tags
Scheduler
Asked by
Stefan
Top achievements
Rank 1
Iron
Share this question
or