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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Restore previous position

Thread ID:

Created:

Updated:

Platform:

Replies:

141287 Dec 4,2018 12:06 PM UTC Dec 19,2018 11:29 AM UTC JavaScript 3
loading
Tags: ejGantt
Tomasz Tomczykiewicz
Asked On December 4, 2018 12:06 PM UTC

Hi,

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

Punniyamoorthi Elangovan [Syncfusion]
Replied On 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); 
                $("#GanttContainer").ejGantt({ 
                    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; 
                ganttObj.destroy(); 
        }) 
We have prepared the sample for your reference, please find the sample link below 
Regards, 
Punniyamoorthi 
 
 


Tomasz Tomczykiewicz
Replied On 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

Punniyamoorthi Elangovan [Syncfusion]
Replied On 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); 
    removeTime(projectData); 
    formatName(projectData); 
    const gantt = $("#GanttContainer") 
        .ejGantt({ 
            dataSource: projectData, 
            dateFormat: DATE_FORMAT.SYNCFUSION, 
            create: function (args) { 
                this.setScrollTop(previousScrollTop); 
               } 
            //.. 
        }); 
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. 
Regards, 
Punniyamoorthi 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;