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

RadGridView VirtualQueryableCollectionView Selected items

14 Answers 575 Views
Data Virtualization
This is a migrated thread and some comments may be shown as answers.
geblack
Top achievements
Rank 1
geblack asked on 11 Aug 2011, 09:51 PM
While viewing a virtual collection in the gridview if I load the first page, select a row, then move down to a page after the second page and attempt to close the multi selection with the shift key (multi-select across pages) the following error is thrown, any way to prevent this short of removing extended selection from the grid (currently have functionality tied to multiselect), maybe reset selection when page moves?:

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

Sort by
0
Maya
Telerik team
answered on 17 Aug 2011, 12:17 PM
Hello Geblack,

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.
 

Greetings,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
geblack
Top achievements
Rank 1
answered on 17 Aug 2011, 06:01 PM
Using deferred scrolling the only items which are loaded in the VirualQueryableCollectionView are the items on the startindex and loadsize page on which the scroll stopped. In a virtual collection this leaves the array elements between the first page and the page where the scrolling stopped in an uninitialized state (no data).

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?
0
geblack
Top achievements
Rank 1
answered on 23 Aug 2011, 02:22 PM
Was there any more information concerning this issue? I have attempted to work around the issue by loading the missing elements but since the call to load the data from the server is asynchronous the grid still throws the cellinfo error before the data is retrieved.
0
geblack
Top achievements
Rank 1
answered on 23 Aug 2011, 02:24 PM
Another issue that I ran into while trying to work around this issue is that the closure of the selecteditems (shift-click) event does not contain all of the addeditems which the selection is covering
0
Maya
Telerik team
answered on 23 Aug 2011, 02:49 PM
Hello Geblack,

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.
 

Kind regards,
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 >>

0
geblack
Top achievements
Rank 1
answered on 23 Aug 2011, 03:33 PM
OK, since it is confirmed that the optimal behavior cannot be made to work (SelectedItems acrossed unloaded 'pages' in a VirtualQueryableColelctionView) what I have come up with is a way to test whether the selecteditems are currently loaded in the collection. If an empty object is encountered in the selecteditems then the selection is canceled.

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;
}

0
geblack
Top achievements
Rank 1
answered on 06 Sep 2011, 07:00 PM
OK, so canceling the selection if the items are not loaded was not acceptable to the end user, I have attempted the same logic to identify the startindex and number of items to load and called the remote service to load the items and upon return I am loading them into the virtualqueryablecollectionview. I am still getting a cellinfo error on the grid when I attempt to use the select method on the items returned from the service.

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?
0
Maya
Telerik team
answered on 07 Sep 2011, 09:52 AM
Hello Geblack,

My guess would be that the LoadSize and VirtualItemCount are not set properly according to the number of items you want to select. 
 

All the best,
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 >>

0
geblack
Top achievements
Rank 1
answered on 07 Sep 2011, 01:51 PM
OK so VirtualItemCount is already set by a previous load operation on the query to the totalitemcount of the returned query.

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
0
Valdo
Top achievements
Rank 1
answered on 14 Dec 2011, 02:57 PM
Any progress on this issue?
0
Gene
Top achievements
Rank 1
answered on 22 Jan 2012, 09:41 PM
I see the issue with selection and data availability was resolved in the 2011.3 release, thank you!.

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?
0
Gene
Top achievements
Rank 1
answered on 24 Jan 2012, 03:49 PM
I spoke too soon, it does appear that the unloaded rows that are part of the selection are loading in the background but once loaded they are still not a part of the selecteditems collection in the grid itself. This is using deferred scrolling, synch or async data loading in the grid

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
---------------

0
Gene
Top achievements
Rank 1
answered on 27 Jan 2012, 10:21 PM
bump, really would like this to work
0
Chris
Top achievements
Rank 1
Iron
answered on 27 Apr 2021, 10:21 AM
Subscribe to the VirtualQueryableCollectionView's ItemsLoaded event and select the item there.  Easy peasy.
geblack
Top achievements
Rank 1
commented on 28 Apr 2021, 04:58 AM

Thanks mate, its been nine years and I don't even recall the issue at this point, let alone whether it was resolved. cheers :)
Tags
Data Virtualization
Asked by
geblack
Top achievements
Rank 1
Answers by
Maya
Telerik team
geblack
Top achievements
Rank 1
Valdo
Top achievements
Rank 1
Gene
Top achievements
Rank 1
Chris
Top achievements
Rank 1
Iron
Share this question
or