Kendo Grid jumps to top after onSave

强颜欢笑 提交于 2019-12-11 16:14:17

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!