dgrid not able to retain the scroll position after performing column sort

871 Views Asked by At

I am using a dgrid that has a horizontal scroll bar and column sorting. When the user scrolls to the last column and sorts the column, the scroll position is not retained by dgrid. How can I retain the scroll bar position after the sort is completed ?

var grid = new (declare([OnDemandGrid, DijitRegistry, ColumnResizer]))({
            id: "grid",
            store: storeForGrid,
            maxRowsPerPage: 3,
            columns: [ {
                field: "Name",
                label: "Name"
            }, {
                field: "LastName",
                label: "Last Name"
            }, {
                field: "BookNumber",
                label: "Book Number"
            }, {
                field: "MaxDays",
                label: "Max. Days"
            }, {
                field: "MinDays",
                label: "Min. Days"
            } ]
        }, this.grid);

I tried to implement the 'dgrid-sort' event callback. By this time the scrollLeft position is reset-ted to 0. Thanks.

1

There are 1 best solutions below

0
On

Passing keepScrollPosition: true in your constructor arguments object should do exactly what you are asking for.

https://github.com/SitePen/dgrid/blob/v0.4.0/doc/components/core-components/OnDemandList-and-OnDemandGrid.md#property-summary