We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Restore previous position


I recreate Gantt chart and it sets the visible section of the chart to the top. I want to stay in the same visible section. How can I achieve this?

Best regards,
Tomasz Tomczykiewicz

3 Replies

PE Punniyamoorthi Elangovan Syncfusion Team December 5, 2018 01:22 PM UTC

Hi Tomasz, 
Thank you for contacting Syncfusion support. 
We have analyzed your requirement. In Gantt we can get the current top position of the scrollbar using scrollbar instance and dynamically set that scrollTop using setScrollTop public method. Please refer the below code example for this 
<script type="text/javascript"> 
        var previousScrollTop = 0;   
     $(function () { 
          var data = ej.DataManager(projectData); 
                    dataSource: data, 
                     actionComplete: function (args) { 
                        if (args.requestType == "create") { 
                            this.setScrollTop(previousScrollTop); // updating the Gantt with previous scrollTop value 
$("#updateRecord").click(function () { 
      //codes for getting the previous scrolltop value 
        var ganttObj = $("#GanttContainer").ejGantt("instance"), 
                scrollObj = $("#GanttContainer").find(".e-ganttviewerbodyContianer").ejScroller("instance"); 
                previousScrollTop = scrollObj.model.scrollTop; 
We have prepared the sample for your reference, please find the sample link below 

TT Tomasz Tomczykiewicz December 18, 2018 02:32 PM UTC

Hi Punniyamoorthi,

Thank you for your replay, but your solution doesn't work on my case.
I attached my code with your solutions and please check why it doesn't work.
First, you have to open a terminal in the folder and install all npm packages (command "npm i"). Then you can open file index.html.

Best regards,
Tomasz Tomczykiewicz

Attachment: setScrollTop_76fb462c.zip

PE Punniyamoorthi Elangovan Syncfusion Team December 19, 2018 11:29 AM UTC

Hi Tomasz,  
Sorry for the inconvenience caused. 
We have checked your attached sample. We suggest you to set the previous scrollTop value to the Gantt control in create client side event to overcome the reported issue. Please refer the below code example for this 
function createGantt() { 
    const projectData = cloneDeep(sampleData); 
    const gantt = $("#GanttContainer") 
            dataSource: projectData, 
            dateFormat: DATE_FORMAT.SYNCFUSION, 
            create: function (args) { 
We have prepared the sample for your reference, please find the sample link below 
Note: In our previous attached sample we had pass the Data to Gantt control using ejDataManager support, in this scenario the actionComplete client side event will trigger with argument requestType value as “create” once the Gantt control gets rendered. 

Live Chat Icon For mobile
Up arrow icon