0
votes

I have created a kendo grid using Asp.Net MVC wrappers. I have included a checkbox for selecting multiple rows made the wiring and everything works ok. However, I have issues, when I change page, or do a filtering as the selecting rows/checkbox disappear.

What is the solution for this problem?

1

1 Answers

2
votes

You need to use .PersistSelection(true) to ensure rows remain selected when changing pages:

@(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.OrderViewModel>()
    .Name("rowSelection")
    .Columns(columns => {
        columns.Bound(o => o.ShipCountry).Width(300);
        columns.Bound(p => p.Freight).Width(300);
        columns.Bound(p => p.OrderDate).Format("{0:dd/MM/yyyy}");
    })
    .Pageable(pageable => pageable.ButtonCount(5))
    .Selectable(selectable => selectable
        .Mode(GridSelectionMode.Multiple))
    .PersistSelection(true)                
    .Navigatable()
    .DataSource(dataSource => dataSource
        .Ajax()                
        .Model(m=>m.Id("OrderID"))
        .PageSize(6)
        .Read(read => read.Action("Orders_Read", "Grid"))
     )

Also ensure you have an id column declared in the DataSource, like .Model(m=>m.Id("OrderID")) in the example, otherwise it will fail.

Full details here.

I had issues with the jQuery grid.select() however:

    var grid = $('#rowSelection').data('kendoGrid');
    var rows = grid.select();

This only seemed to return rows selected on the currently displayed page rather than all the rows selected across all the pages.