Hi James,
This behavior is expected since the grid only has access to the items that are displayed in the current page.
Here is one workaround that might work for your scenario:
01.
BitArray selectedItemsFlags;
02.
bool
selectionRestored =
false
;
03.
// subscribe for this.myGrid.Items.PageChanging | this.myGrid.Items.PageChanged
04.
05.
void
Items_PageChanged(
object
sender, System.EventArgs e)
06.
{
07.
this
.myGrid.SelectedItems.Clear();
08.
this
.Dispatcher.BeginInvoke(
new
System.Action(() =>
this
.RestoreSelectionAfterPageChange()));
09.
}
10.
11.
void
Items_PageChanging(
object
sender, System.ComponentModel.PageChangingEventArgs e)
12.
{
13.
// save current selection
14.
this
.selectedItemsFlags =
new
BitArray(
this
.myGrid.Items.PageSize);
15.
16.
foreach
(var item
in
this
.myGrid.SelectedItems)
17.
{
18.
var index =
this
.myGrid.Items.IndexOf(item);
19.
this
.selectedItemsFlags[index] =
true
;
20.
}
21.
22.
this
.selectionRestored =
false
;
23.
}
24.
25.
private
void
RestoreSelectionAfterPageChange()
26.
{
27.
if
(
this
.selectedItemsFlags ==
null
||
this
.selectionRestored)
28.
return
;
29.
30.
// restore selection
31.
for
(
int
i = 0; i <
this
.selectedItemsFlags.Count; i++)
32.
{
33.
var isSelected =
this
.selectedItemsFlags[i];
34.
35.
if
(isSelected && i <
this
.myGrid.Items.Count)
36.
this
.myGrid.SelectedItems.Add(
this
.myGrid.Items[i]);
37.
}
38.
39.
this
.selectionRestored =
true
;
40.
}
Greetings,
Milan
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items.