System.ArgumentException: Cell is not valid Parameter name: cellInfo
at Telerik.Windows.Controls.GridView.Selection.CellInfoCollection.Contains(GridViewCellInfo cellInfo)
at Telerik.Windows.Controls.GridView.Selection.RowTrackingRootSelectionStateChanger.UpdateCellsSelectionState(DataCellsPresenter cellsPresenter, CellInfoCollection cells, Boolean isSelected)
at Telerik.Windows.Controls.GridView.Selection.RowTrackingRootSelectionStateChanger.UpdateCellSelectionState(LinkedList`1 trackingRoot, CellInfoCollection cells, Boolean isSelected)
at Telerik.Windows.Controls.GridView.Selection.RowTrackingRootSelectionStateChanger.UpdateCellSelectionState(CellInfoCollection cells, Boolean isSelected)
at Telerik.Windows.Controls.GridView.Selection.CellSelectionHandler.SetSelectionState(CellInfoCollection cellsCollection, Boolean isSelected)
at Telerik.Windows.Controls.GridView.Selection.CellSelectionHandler.EndAllowedSelection()
at Telerik.Windows.Controls.GridView.Selection.CellSelectionHandler.EndPendingSelection()
at Telerik.Windows.Controls.GridView.Selection.CellSelectionHandler.EndSelection()
at Telerik.Windows.Controls.GridView.CellSelectionChange.Dispose()
at Telerik.Windows.Controls.GridView.Selection.CompositeSelectionHandler.Items_CollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
at Telerik.Windows.Data.DataItemCollection.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
at Telerik.Windows.Data.DataItemCollection.OnCollectionViewCollectionChanged(NotifyCollectionChangedEventArgs e)
at Telerik.Windows.Data.DataItemCollection.Telerik.Windows.Data.IWeakEventListener<System.Collections.Specialized.NotifyCollectionChangedEventArgs>.ReceiveWeakEvent(Object sender, NotifyCollectionChangedEventArgs e)
at Telerik.Windows.Data.WeakEvent.WeakListener`1.Handler(Object sender, TArgs args)
at Telerik.Windows.Data.QueryableCollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
at Telerik.Windows.Data.VirtualQueryableCollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
at Telerik.Windows.Data.QueryableCollectionView.ProcessSynchronousCollectionChangedWithAdjustedArgs(NotifyCollectionChangedEventArgs originalArguments, Int32 adjustedOldIndex, Int32 adjustedNewIndex)
at Telerik.Windows.Data.QueryableCollectionView.ProcessAsynchronousCollectionChanged(NotifyCollectionChangedEventArgs args)
at Telerik.Windows.Data.QueryableCollectionView.ProcessCollectionChanged(NotifyCollectionChangedEventArgs args)
at Telerik.Windows.Data.VirtualQueryableCollectionView.ProcessCollectionChanged(NotifyCollectionChangedEventArgs args)
at Telerik.Windows.Data.QueryableCollectionView.OnSourceCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
at Telerik.Windows.Data.QueryableCollectionView.Telerik.Windows.Data.IWeakEventListener<System.Collections.Specialized.NotifyCollectionChangedEventArgs>.ReceiveWeakEvent(Object sender, NotifyCollectionChangedEventArgs args)
at Telerik.Windows.Data.WeakEvent.WeakListener`1.Handler(Object sender, TArgs args)
at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
at Telerik.Windows.Data.RadObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
at System.Collections.ObjectModel.ObservableCollection`1.SetItem(Int32 index, T item)
at System.Collections.ObjectModel.Collection`1.set_Item(Int32 index, T value)
at System.Collections.ObjectModel.Collection`1.System.Collections.IList.set_Item(Int32 index, Object value)
at Telerik.Windows.Data.VirtualQueryableCollectionView.LoadItems(Int32 startIndex, IEnumerable items)
at Telerik.Windows.Data.VirtualQueryableCollectionView.<>c__DisplayClass26.<Load>b__25()
14 Answers, 1 is accepted
You need to make sure that the items you want to select are already loaded. Otherwise, the selection will fail. Generally, the items are created once you try to scroll to them.
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

So how would I go about forcing those pages in between to be loaded (method to load the missing data and what event would I intercept and wait for the asynchronous return) so that the selection acrossed unloaded elements in the array would not fail?


The behavior you require is not quite achievable since not all elements are available. Event if you get the first clicked item and the second one, it will not be sure if you will be able to get the correct items in-between as there is no proof whether the index of the second item corresponds to the way it is displayed in the grid.
Furthermore, the items are loaded page per page and if you want to select more than one page, you will get again an exception since not all of them are available.
Maya
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

This allows me to continue to use the Extended selection when it is valid and cancel it when the RadGridView would throw an error because of unloaded data. A better option would be to be able to load the data but I have not found a way to make that work without the grid throwing an error and becoming unusable.
private void radGridView_SelectionChanging(object sender, SelectionChangingEventArgs e)
{
e.Cancel = ViewModel.CancelSelection(radGridView.GetSelectionAnchorItem(), e.AddedItems.LastOrDefault());
}
public bool CancelSelection(object startObject, object endObject)
{
int startIndex = VirtualCollection.IndexOf(startObject);
int endIndex = VirtualCollection.IndexOf(endObject);
if (startIndex > endIndex)
{
int tempIndex = startIndex;
startIndex = endIndex;
endIndex = tempIndex;
}
int indexDiff = endIndex - startIndex;
if (startIndex >-1 && indexDiff > 0)
return ArrayContainsNullValue(startIndex, indexDiff);
return false;
}
private bool ArrayContainsNullValue(int startIndex, int length)
{
// if an empty object is encountered in the array then cancel the selection
for (int x = startIndex; x <= startIndex + length; x++)
if (!(VirtualCollection.GetItemAt(x) is VirtualCollectionItem))
return true;
return false;
}

Also when I view the VirtualQueryableCollectionView after calling the Load method with the offset and collection of entities returned from the service it appears that the VirtualQueryableCollectionView is still empty of elements at that offset. Any explanation of why that would be true after calling the Load method?
My guess would be that the LoadSize and VirtualItemCount are not set properly according to the number of items you want to select.
Maya
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

In this case VirtualItemCount is already set to 24033.
1. A query is issued to the server to load items .Skip(5) and .Take(694) (loadsize on virtualquerycollection is set to 40 but doesn't seem relevent at this point)
2. Async return from query is reached and .Load(5, entitiesreturned) is issued to the VirtualQueryableCollection
3. Examination of VirtualQueryableCollection at this point does not show that the entitiesreturned were loaded.
4. Message is sent to the view containing the entitiesreturned collection
5. Entitiesreturned collection is used in RadGridView.Select(entitiesreturned)
cellinfo error generated at this point
If this is not possible to do (as stated in a previous reply) are there going to be any changes in RadGridView when using a VirtualQueryableCollectionView to enable cross page selection in the Q3 release?
In addition, are there any plans or guidance to enable the ExportGrid functionality to work with a VirtualQueryableCollectionView source?
In this scenario VirtualItemCount is already set and unless I am mistaken LoadSize on the VirtualQueryableCollection does not come into play since the Load is explicitly performed on the return of the query for the selected items


The only issues that I have now are:
1. The grid sends out a flurry of data requests when the selection is large. i.e. 20k items with 100 item page size sends out 200 RIA calls when selecting all items. This is not a problem in and of itself (expected since the previous problem was that the data wasn't avaible) but it appears these calls are not managed and are sent out as quickly as they can be contructed. Having that many open connections and data requests at once is problematic and usually results in a timeout. Is there any way to tell RadGridView to queue the calls or any suggestions on metering the selection process to avoid this situation?
2. <ctrl>A still does not select all items, only those on the current page (but given the previous request behavior, maybe thats a good thing, lol)
Follow on question
Is there any way that this can be tied in with export so that the data is available when exporting?

If I manully reassert the extended selection (shift click) on the last selected row visible in the grid after the intermediary data is loaded it does then select all the intermediary rows. Unfortunately I cannot emulate that action in code. Since the SelectedItems never contains all of the actual selection (it only ever contains those items that were visible on the first page of viewed data where the selection began and the items that were part of the selection on the last page viewed where the selection ended). In the example below the selecteditem count is 6 instead of 11 and selecteditems only contains the first and last page of selected data. Additionally in the UI it is only showing the selected data from the first and last page.
This is frustrating because it is very close to working but I am unable to grab onto the correct data or an event to complete the extended selection!
---------- begin selection first page
nonselected item
nonselected item
nonselected item
begin selection
selected item
selected item
selected item
---------
--------intermediary data in non viewed scoll pages not selected but intended to be selected using extended selection
nonselected item
nonselected item
nonselected item
nonselected item
nonselected item
--------------- end selection last viewed page
selected item
selected item
selected item
end selection
nonselected item
nonselected item
nonselected item
nonselected item
---------------

