kendoui:grid - 在网格的顶部和底部设置寻呼机

问题描述 投票:2回答:2

有一种简单的情况找不到解决方案。 Kendo-UI仅在底部实现网格分页。我试图让它在顶部显示寻呼机,但它变得无法点击。我认为我的克隆部分是错误的,但不知道如何解决它。先谢谢你们。

这里是脚本和jsp的一部分......

<kendo:grid name="grid" pageable="true" dataBound="onBound">
    <kendo:dataSource serverPaging="true" serverSorting="true">
        <kendo:dataSource-transport>
            <kendo:dataSource-transport-read url="api/items" />
        </kendo:dataSource-transport>
        <kendo:dataSource-schema data="data" total="total" />
    </kendo:dataSource>
    <kendo:grid-columns>
        <kendo:grid-column title="id" field="itemId"></kendo:grid-column>
    </kendo:grid-columns>
</kendo:grid>



<script type="text/javascript">
    function onBound() {
        var grid = $("#grid");
        grid.find(".k-grid-pager")
            .clone()
            .insertBefore(grid.find(".k-grid-header"))
            .addClass("pagerTop").css("border-width", "0 0 1px 0");
    }   
</script>
javascript jquery kendo-ui kendo-grid
2个回答
6
投票

试试这个,我希望它有所帮助。

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


0
投票

我使用上面的代码并进行了一些调整以使其工作。我把它变成了JS方法。

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();
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.