eu81273 / angular.treeview

AngularJS based Treeview (no jQuery)
MIT License
405 stars 223 forks source link

Tree view programmatically Selected item does not scrolled into view #35

Closed RamaduraiJayaraman closed 9 years ago

RamaduraiJayaraman commented 9 years ago

I am using anjular treeview. I kept this controll inside the div and i set both scroll bar to navigate the tree view node from top to bottom.

Requirement is that Select/Focus the tree view node when ng grid cell is clicked based on validation. As per the requirement corresponding Tree view node is selected once grid cell is clicked.

Problem is that if selected tree view node is not in visible area, user have to manually scroll the div where Tree view have been kept to view Selected/Focused tree view node.

I want to programmatically scroll the tree view to view the focused node.

RamaduraiJayaraman commented 9 years ago

I solved the issue using below Jquery. selected item does scrolled into view properly.

var $s = $('#divTree'); // Get Container Div var optionTop = $s.find("#" + element.ElementId).offset().top; // Identify the selected item var selectTop = $s.offset().top; $s.scrollTop($s.scrollTop() + (optionTop - selectTop) - 20);