简体   繁体   中英

Kendo Grid jumps to top after onSave

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.

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);
}

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);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM