问题
I have a grid that i need to set:
scrollable: {
virtual: true
},
When users edit a cell then updates (or onSave(e)) their changes. The grid resets back to the top of the page. I don't know why. Users lose their place every time they try to change a cells contents.
When i make
scrollable: false,
it stays put. I think this is a huge bug in Telerik Kendo. Has anyone figured out how to stay in place on the grid after saving changes?
UPDATE
This problem only occurs in IE 11. Unfortunately my client can only use IE11.
回答1:
I think this works for you:
Use GridViewRowInfo
to get row info of selected row and set scroll to your custom row and column.
if (this.radGridView1.SelectedCells.Count > 0)
{
GridViewRowInfo row = this.radGridView1.SelectedCells[0].RowInfo;
radGridView1.TableElement.ScrollTo(row.Index, 0);
}
回答2:
The answer is to save your current location before you bind.
in
onGridBinding(){
_currentLeftPosition = $(".k-virtual-scrollable-wrap").scrollLeft();
}
in onGridBound(){
//Go Back to previous position
var vs = mainGrid.wrapper.find('.k-grid-content').data('kendoVirtualScrollable');
var scrollGridContentOffsetTop = mainGrid.wrapper.find('.k-grid-content').offset().top;
var selectContentOffsetTop = mainGrid.content.offset().top;
var distanceTop = selectContentOffsetTop - scrollGridContentOffsetTop;
var scrollTop = vs.verticalScrollbar.scrollTop();
$("#mainGrid div.k-virtual-scrollable-wrap").animate({scrollTop: distanceTop + scrollTop,scrollLeft: _currentLeftPosition}, 0);
$("#mainGrid div.k-scrollbar-vertical").animate({scrollTop: distanceTop + scrollTop}, 0);
}
来源:https://stackoverflow.com/questions/46920023/kendo-grid-jumps-to-top-after-onsave