Gantt set slot size using Javascript

1 Answer 132 Views
Gantt
Matthew
Top achievements
Rank 1
Iron
Iron
Matthew asked on 16 Jul 2021, 03:39 PM

Hello,

I would like the user to have the ability to zoom in and out of a Day view.

I've added the following to the toolbar;

<Toolbar>
   <ClientTemplate>
        <a class="k-button" onclick="return ganttZoomIn(this, event)" title="Zoom In">+</a>
        <a class="k-button" onclick="return ganttZoomOut(this, event)" title="Zoom Out">-</a>
    </ClientTemplate>
</Toolbar>  

and the following javascript;

function ganttZoomIn(button, ev)
{
   var gantt = $find("<%= RadGannt1.ClientID %>");
   gantt._viewsData[0].slotSize += 10;
}

function ganttZoomOut(button, ev)
{
   var gantt = $find("<%= RadGantt1.ClientID %>");
   gantt._viewsData[0].slotSize -= 10;
}

But the changes to the slot size is not changing the Gantt.

Can the slot size be updated using javascript?

Thanks,

Matt

1 Answer, 1 is accepted

Sort by
1
Accepted
Peter Milchev
Telerik team
answered on 21 Jul 2021, 08:48 AM

Hi Matt,

You can set the slotSize of the current view of the underlying Kendo Gantt widget and then call the repaint() method of the Gantt to update the slot sizes visually:

function ganttZoomIn(button, ev) {
    var gantt = $find("<%= RadGantt1.ClientID %>");
    gantt.get_kendoWidget().view().options.slotSize += 10;
    gantt.repaint();
}

function ganttZoomOut(button, ev) {
    var gantt = $find("<%= RadGantt1.ClientID %>");
    gantt.get_kendoWidget().view().options.slotSize -= 10;
    gantt.repaint();
}

Regards,
Peter Milchev
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Matthew
Top achievements
Rank 1
Iron
Iron
commented on 21 Jul 2021, 09:16 AM

Thank you. works perfectly
Tags
Gantt
Asked by
Matthew
Top achievements
Rank 1
Iron
Iron
Answers by
Peter Milchev
Telerik team
Share this question
or