Skip to content Skip to sidebar Skip to footer

Kendoui:grid - Set Pager On Top And Bottom Of The Grid

Have kind of simple situation can't find solution for. Kendo-UI only implements grid pagination on the bottom. I tried to make it show pager on top, but it becomes unclickable. I

Solution 1:

Try this, I hope it helps.

function BindTopPager(e) {

    var gridView = $('#grid').data('kendoGrid'),
        pager = $('#div .k-pager-wrap'),
        id = pager.attr('id') + '_top',
        $grid = $('#grid'),
        topPager;

    if (gridView.topPager === null) {
        // create top pager div
        topPager = $('<div/>', {
            'id': id,
            'class': 'k-pager-wrap pagerTop'
        }).insertBefore($grid.find('.k-grid-header'));

        // copy options for bottom pager to top pager
        gridView.topPager = new kendo.ui.Pager(topPager, $.extend({}, gridView.options.pageable, { dataSource: gridView.dataSource }));

        // cloning the pageable options will use the id from the bottom pager
        gridView.options.pagerId = id;

        // DataSource change event is not fired, so call this manually
        gridView.topPager.refresh();
    }
}

var grid = $("#grid").data("kendoGrid");
grid.bind("dataBound", BindTopPager);
grid.dataSource.fetch();

DEMO


Solution 2:

I used the above code and made some adjustments to make it work. I made it into a JS method.

function moveNavigationToTopOnGrid(gridSelector) {
    var grid = $(gridSelector).data("kendoGrid"),
        pager = $(gridSelector + ' .k-pager-wrap'),
        id = pager.prop('id') + '_top',
        $grid = $(gridSelector);

    if (!grid.topPager) {
        // create top pager div
        topPager = $('<div/>', {
            'id': id,
            'class': 'k-pager-wrap pagerTop'
        }).insertBefore($grid);

        // copy options for bottom pager to top pager
        grid.topPager = new kendo.ui.Pager(topPager, $.extend({}, grid.options.pageable, { dataSource: grid.dataSource }));

        // cloning the pageable options will use the id from the bottom pager
        grid.options.pagerId = id;

        // DataSource change event is not fired, so call this manually
        grid.topPager.refresh();
    }
}

Post a Comment for "Kendoui:grid - Set Pager On Top And Bottom Of The Grid"