Author Topic: Get and set scroll position in angular  (Read 1800 times)

Digitalsoft

  • Pro OEM
  • Newbie
  • *
  • Posts: 49
    • View Profile
Get and set scroll position in angular
« on: September 21, 2020, 11:30:05 am »
Hi,
I am trying to get and set the scroll position in angular based on these references
https://paramquery.com/pro/tutorial#topic-methods
https://paramquery.com/api/scrollbar#option-cur_pos
This is my grid instance in the component
grid: pq.gridT.instance;

this is how I trying to get the scroll in grid inside beforeTableView event and complete event
 beforeTableView: function (evt, ui) {   
              if(self.grid) {
                let $pqScrollbar = self.grid.find("div.pq-sb-vert").pqScrollBar();
                console.log($pqScrollbar)
              }
}

but getting error like 'ERROR TypeError: self.grid.find is not a function'. Find the attachment for the error. Kindly help in how to get and set scroll position in angular.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: Get and set scroll position in angular
« Reply #1 on: September 21, 2020, 02:33:03 pm »
PQ Pro uses native scrollbar and its position can be obtained simply from grid.scrollX() and grid.scrollY() methods.

Code: [Select]
beforeTableView: function (evt, ui) {   
   var y = this.scrollY(); //returns vertical position of scrollbar in pixels.
}

However if you are trying to access records position inside the viewport in beforeTableView event.

Code: [Select]
beforeTableView: function (evt, ui) {   
   var initV = ui.initV; //returns rowIndx of first rendered row in the unfrozen viewport.
   var finalV = ui.finalV; //returns rowIndx of last rendered row in the unfrozen viewport.
}