Restore previous position
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
SIGN IN To post a reply.
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);
$("#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
TT
Tomasz Tomczykiewicz
December 18, 2018 02:32 PM UTC
Hi Punniyamoorthi,
Attachment: setScrollTop_76fb462c.zip
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);
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
Link: http://www.syncfusion.com/downloads/support/directtrac/223283/ze/setScrollTop_76fb462c-1388568475
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
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
TT Tomasz Tomczykiewicz
- Dec 4, 2018 12:06 PM UTC
- Dec 19, 2018 11:29 AM UTC