How can I enable the autoscroll in Dhtmlx grid.
I have disabled autoscroll manually to prevent below situation.
example :
if I double click on the last/ second last cell. the cell vertical scroll happens and the position of the cell appears at the beginning of the grid. I don’t want this behavior.
So, I have disabled the autoScroll by:
_grid.moveToVisible = () => { };_
bt later I need to enable autoScroll feature as I have to focus the selected row in grid.
How can I do this ?
Thanks,
Avinash Tambe
sematik
November 5, 2020, 5:10pm
#2
There is method to swap the autoscroll on/off dynamically.
You need to redefine the moveToVisible function back again to enable the autoscroll:
_grid.moveToVisible=function(cell_obj, onlyVScroll){
if (this.pagingOn){
var newPage=Math.floor(this.getRowIndex(cell_obj.parentNode.idd) / this.rowsBufferOutSize)+1;
if (newPage!=this.currentPage)
this.changePage(newPage);
}
try{
if (cell_obj.offsetHeight){
var distance = cell_obj.offsetLeft+cell_obj.offsetWidth+20;
var scrollLeft = 0;
if (distance > (this.objBox.offsetWidth+this.objBox.scrollLeft)){
if (cell_obj.offsetLeft > this.objBox.scrollLeft)
scrollLeft= cell_obj.offsetLeft - (this.objBox.offsetWidth - cell_obj.offsetWidth) +5
} else if (cell_obj.offsetLeft < this.objBox.scrollLeft){
distance-=cell_obj.offsetWidth*2/3;
if (distance < this.objBox.scrollLeft)
scrollLeft=cell_obj.offsetLeft-5
}
if ((scrollLeft)&&(!onlyVScroll))
this.objBox.scrollLeft=scrollLeft;
}
if (!cell_obj.offsetHeight){
var mask=this._realfake?this._fake.rowsAr[cell_obj.parentNode.idd]:cell_obj.parentNode;
distance = this.rowsBuffer._dhx_find(mask)*this._srdh;
}
else
distance = cell_obj.offsetTop;
var distancemax = distance + cell_obj.offsetHeight+38;
if (distancemax > (this.objBox.offsetHeight+this.objBox.scrollTop)){
var scrollTop = distancemax-this.objBox.offsetHeight;
} else if (distance < this.objBox.scrollTop){
var scrollTop = distance-5
}
if (scrollTop)
this.objBox.scrollTop=scrollTop;
}
catch (er){}
}
this is the private API and is not intended for the public usage.