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

Selected task focus after data reload

Dear Team,


I was working on persisting selected task focus after refreshing data (manual, auto refresh, after drag&drop/doubleclick action, change date range etc.)

It is quite easy to keep selected row data in component (TaskId) - after refresh it is possible to use:

scrollToTask(selectedTaskId)


BUT this does not scroll vertically - and I didn't found any API for that.

Current workaround is saving scrollPosition -  from

 this.visualPlanningObj.ganttChartModule?.scrollElement?.scrollTop


BUT this is not efficient (e.g. when user changes date range, or expand some of deep nested tasks - scroll height changes)


Please advice what is the best way to persist (or calculate) vertical scroll with/without virtualization.




1 Reply

UA Udhayakumar Anand Syncfusion Team April 26, 2023 01:53 PM UTC

Hi RolJan,


Thank you for contacting us. We understand your concern and have reviewed your query. You can achieve your requirement by using the actionComplete event with the requestType of scroll and action of verticalScroll. In this event, you can store the scroll value in a public variable. While refreshing the Gantt, the dataBound event will get triggered. In that event, you can set the scroll bar to the previous position by using the setScrollTop method. We have a code snippet and a sample link that you can refer to, which will guide you on how to implement this.



Code Snippet :

/*app.component.ts*/

dataBound() {

    this.gantt.setScrollTop(this.setscrol);

  }

 

 

actionComplete(actionCompleteArgs) {

    var gantt =

      document.getElementsByClassName('e-gantt')[0]['ej2_instances'][0];

    if (

      actionCompleteArgs.requestType === 'scroll' &&

      actionCompleteArgs.action === 'VerticalScroll'

    ) {

      this.setscrol = actionCompleteArgs.scrollTop;

    }

  }

 


Sample Link : https://stackblitz.com/edit/angular-lp7jtr-effgwn?file=src%2Fapp.component.html,src%2Fapp.component.ts


We hope this solution addresses your query and helps you persist the vertical scroll efficiently, If you have any further queries, please do not hesitate to contact us.


Regards,

Udhayakumar



Loader.
Live Chat Icon For mobile
Up arrow icon