This is a migrated thread and some comments may be shown as answers.

Grid MultiSelection with pageable set to true

3 Answers 279 Views
Grid
This is a migrated thread and some comments may be shown as answers.
wang
Top achievements
Rank 1
wang asked on 21 Nov 2012, 12:47 AM
Hello Telerik,

We are using Kendo Grid Control to display a large amount of data, and the pageable is set to true. We add a template column of a checkbox within each row to make a multiselection scenario. But the checkbox status will not stay there after switching page.

So i was wondering how could archieve this, or is there another work around?

3 Answers, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 21 Nov 2012, 07:42 AM
Hello Wang,

Grid selection is a class(.k-state-selected) applied for selected cells/rows. It can be applied only for the items in current page and is not persisted.

All the best,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
PAUL
Top achievements
Rank 1
answered on 05 Mar 2013, 12:36 PM
Considering that nearly EVERY application would want to persist the check boxes that are clicked when paging, I was wondering if you could tell us how we can work around this. I have been looking everywhere with no luck
0
Nikolay Rusev
Telerik team
answered on 08 Mar 2013, 08:23 AM
Hello Paul,

Persistence of selected items over repaints depends entirely on the concrete scenario. There two use cases that I can think of:
 - persisting of the index of selected row in the page - this way on paging same row(with different underlying data item) will be selected.
/sample code/

function saveSelected() {
 //list of all selectable rows in the Grid
 var allItems = grid.items();
 
 //get a list of selected items indices
 var items = grid.select().map(function() { return allItems .index($(this)); });
 
 //pseudo code for saving indices
 <some storage>.save(items);
}

function loadSelected() {
 //all selectable items
 var allItems = grid.items();
 
 //pseudo code for loading saved indices from the storage
 var selected = <some storage>.load();
 
 //apply visual selected state
 $.each(selected, function() { allItems.eq(this).addClass("k-state-selected"); });
}

 - persist the selection of actual data item - what this mean is that for every selected row you must get the actual data item and mark it as selected. Then on every refresh of the grid you will have to apply the selected style.

As I said it entirely depend on the use case and can be implemented in many different ways. Here few links showing some possible implementations:
http://www.kendoui.com/forums/mvc/grid/persisting-user-selections-in-kendo-grid.aspx
http://www.kendoui.com/code-library/web/grid/preserve-grid-state-in-a-cookie.aspx
http://sympletech.com/kendo-ui-grid-multiselect-with-checkboxes/
Regards,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
wang
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
PAUL
Top achievements
Rank 1
Share this question
or