Error binding GridView to DomainDataSource

13 posts, 0 answers
  1. Corey Gaudin
    Corey Gaudin avatar
    57 posts
    Member since:
    Nov 2009

    Posted 14 Dec 2009 Link to this post

    I am using the new 12/8/09 version of the GridView. I am creating a DomainDataSource in code in a ViewModel that stays in memory statically.

    I have a popup (just using a RadWindow) that I set its content to a XAML that is just a GridView. That XAML's UserControl Object's DataContext is set to the ViewModel that created the DomainDataSource.

    The GridView acts fine with data is actually returned. However, when the DomainDataSource returns no records, the next time you pull actual records, the GridView binds to the Domain Data Source I get an error from RIA Service side.

    "No method 'Count' on type System.Linq.Querable' is compatible with the supplied arguments"

    The StackTrace points to the Ria.OperationBase.InvokeCompleteAction().

    Now before you say it is RIA Service that has the issue, it works perfectly fine with a regular DataGrid from the silverlight toolkit. My best guess is that Ria Service makes the call with a new Query Parameter and the result is no records, it changes the EntitySet and the DomainDataSource then changes its EntityCollectionView to have no records, which fires off that it changed, and when the GridView binds to the change, it forces EntityCollectionView to do a Count (maybe initiated from the GridView?) and bombs out.


    To be clear, I updated to 12/8 because I was getting a different error with grouping. Where if it pulled empty records it would give an error on that the property grouped on does not exist on object Entity (which is the RIA service object model). So my guess is this is something all related, its just that the GridView Fixed the Grouping issue, and now there is another problem with Empty records coming back.

    Also, my ViewModel stays in memory at all times, but the XAML is recreated when I pop up that GridView. So I am not sure how this will help. It would be very hard to give you code since it is all propriatery. However, Creating an in memory View Model that has a code DomainDataSource that gets setup from the constructor of the ViewModel. When the popup occurs, the XAML contructor code-behind adds a QueryParameter to the DomainDataSource in the ViewModel that gets it to auto load.

    Get it to load empty data on one popup, close it, then get it to load some data on another popup.
  2. Corey Gaudin
    Corey Gaudin avatar
    57 posts
    Member since:
    Nov 2009

    Posted 14 Dec 2009 Link to this post

    I attached a link to the exact problem in a simple RIA Service App (stripped down to show just this problem).

    Issue Test Here

    It uses the Northwind DB against Contacts.

    To test the problem, do a search for "f" to verify data returns; do a search (filter) for "ABCABC" which will return nothing this time; then do a search for "f" again which will give the "Count" on Querable error.

    Thanks
    CodeFuzion 
  3. DevCraft banner
  4. Corey Gaudin
    Corey Gaudin avatar
    57 posts
    Member since:
    Nov 2009

    Posted 16 Dec 2009 Link to this post

    Did you guys take a look at this yet?
  5. Corey Gaudin
    Corey Gaudin avatar
    57 posts
    Member since:
    Nov 2009

    Posted 16 Dec 2009 Link to this post

    I still have yet to get a response. Please Help!
  6. Stefan Dobrev
    Admin
    Stefan Dobrev avatar
    790 posts

    Posted 17 Dec 2009 Link to this post

    Hello Corey,

    First of all sorry for the late reply.

    After some debugging I was able to find out the problem. It lays down into the fact that DomainDataSource returns Enumerable.Empty<Entity>() when there are no matching items. In this case we cannot correctly resolve the element type, which is Customer in your case and an exception is thrown when the actual items are returned.

    Good news is that we are currently working on a fix in our code base that will handle this behavior. We are doing our best to include this fix in the next latest internal release.


    Greetings,
    Stefan Dobrev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  7. Corey Gaudin
    Corey Gaudin avatar
    57 posts
    Member since:
    Nov 2009

    Posted 18 Dec 2009 Link to this post

    Any word on an update to the Grid Control yet?
  8. Stefan Dobrev
    Admin
    Stefan Dobrev avatar
    790 posts

    Posted 18 Dec 2009 Link to this post

    Hi Corey,

    The fix will be included in the next latest internal build. We are going to publish it till the end of the week.

    All the best,
    Stefan Dobrev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  9. Corey Gaudin
    Corey Gaudin avatar
    57 posts
    Member since:
    Nov 2009

    Posted 21 Dec 2009 Link to this post

    It looks as if a internal build drop was released 12/20. Does this have the fix or will the next?
  10. Corey Gaudin
    Corey Gaudin avatar
    57 posts
    Member since:
    Nov 2009

    Posted 21 Dec 2009 Link to this post

    It appears to have fixed my original issue (the 1219 version) however I have a new issue now. It appears the Telerik GridView is trying to validate the model it is bound to, even though it is in ReadOnly Mode.

    Now when I add in an item (through a DataForm - so DataForm and Telerik GridView bound to same code-behind DomainDataSource), and the Telerik GridView is Read-Only and the DataForm is what edits/deletes/creates I save it (after I fix Validation Issues from Data Form), it bubbles outside of silverlight and causes a White Screen of Death with the following Stack Trace below.

    To be clear, I intentially make it not validate correctly at first, then fix it (in the DataForm), and submit the changes, it appears that, even though it is valid, the GridView throws a un-recoverable Error of the Validation not being correct.

    StackTrace on Validation Issue with not entering in a Description:

    Unhandled Error in Silverlight Application
    Code: 4004   
    Category: ManagedRuntimeError      
    Message: System.ComponentModel.DataAnnotations.ValidationException: You must set a Component Description
       at Telerik.Windows.Controls.GridView.GridViewDataControl.RaiseDataErrorEvent(DataErrorEventArgs args)
       at Telerik.Windows.Controls.GridView.EditContext.CommitCurrentEdit(GridViewRow gridViewRow)
       at Telerik.Windows.Controls.GridView.EditContext.PerformRowEditEnded(GridViewCell currentCell)
       at Telerik.Windows.Controls.GridView.EditContext.CommitCellEdit(GridViewCell currentCell, Boolean isLeavingRow)
       at Telerik.Windows.Controls.GridView.EditContext.CanCellBecomeCurrent(GridViewCell cell)
       at Telerik.Windows.Controls.GridView.GridViewCell.CanCellBecomeCurrent()
       at Telerik.Windows.Controls.GridView.GridViewCell.OnCoerceIsCurrent(DependencyObject target, Object baseValue)
       at Telerik.Windows.PropertyMetadata.CoerceValue(DependencyObject d, DependencyPropertyChangedEventArgs e, CoerceValueCallback callback)
       at Telerik.Windows.PropertyMetadata.<>c__DisplayClass1.<Create>b__0(DependencyObject d, DependencyPropertyChangedEventArgs e)
       at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object newValue, Object oldValue)
       at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet, Boolean isSetByStyle, Boolean isSetByBuiltInStyle, PropertyInvalidationReason reason)
       at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value)
       at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
       at Telerik.Windows.Controls.GridView.GridViewCell.set_IsCurrent(Boolean value)
       at Telerik.Windows.Controls.GridView.GridViewRow.MakeFirstEnabledCellCurrent()
       at Telerik.Windows.Controls.GridView.GridViewRow.OnIsCurrentChanged(Boolean newValue)
       at Telerik.Windows.Controls.RadRowItem.IsCurrentChangedCallback(DependencyObject sender, DependencyPropertyChangedEventArgs e)
       at Telerik.Windows.PropertyMetadata.<>c__DisplayClass1.<Create>b__0(DependencyObject d, DependencyPropertyChangedEventArgs e)
       at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object newValue, Object oldValue)
       at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet, Boolean isSetByStyle, Boolean isSetByBuiltInStyle, PropertyInvalidationReason reason)
       at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value)
       at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
       at Telerik.Windows.Controls.DataControl.PersistIsCurrentPropertry(RadRowItem container, Object dataItem)
       at Telerik.Windows.Controls.GridView.GridViewDataControl.RestoreItemPropeprties(Object item, GridViewRow gridViewRow)
       at Telerik.Windows.Controls.GridView.GridViewDataControl.PrepareContainerForItemOverride(DependencyObject element, Object item)
       at Telerik.Windows.Controls.GridView.BaseItemsControl.Telerik.Windows.Controls.GridView.IGeneratorHost.PrepareItemContainer(DependencyObject container, Object item)
       at Telerik.Windows.Controls.GridView.GridViewItemContainerGenerator.System.Windows.Controls.Primitives.IItemContainerGenerator.PrepareItemContainer(DependencyObject container)
       at Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.InsertContainer(Int32 childIndex, UIElement container, Boolean isRecycled)
       at Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.InsertRecycledContainer(Int32 childIndex, UIElement container)
       at Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.AddContainerFromGenerator(Int32 childIndex, UIElement child, Boolean newlyRealized)
       at Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)    
  11. Corey Gaudin
    Corey Gaudin avatar
    57 posts
    Member since:
    Nov 2009

    Posted 21 Dec 2009 Link to this post

    Ah interesting, it does not happen every time. I cannot pin-point what is making it occur.
  12. Stefan Dobrev
    Admin
    Stefan Dobrev avatar
    790 posts

    Posted 28 Dec 2009 Link to this post

    Hi Corey,

    This is definitely a bug on our side, because no edit operation should be initiated when the grid is read only mode. We will investigate this issue and prepare a fix in one of next latest internal build.

    Meanwhile you can implement a simple workaround. You can attach to the DataError event of the grid and set that event as handled in the event args. This way the grid will absorb the exception and it will not be thrown. Here is a sample code to do this:
    this.gridView.DataError += (s, args) => args.Handled = true;

    Thanks for pointing this issue. I have updated your Telerik points.

    All the best,
    Stefan Dobrev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  13. Nedyalko Nikolov
    Admin
    Nedyalko Nikolov avatar
    871 posts

    Posted 04 Jan 2010 Link to this post

    Hi Corey Gaudin,

    I've fixed an issue based on your stack trace, but I'm not completely sure that your problem will be solved. Can you send me a sample application (based on Northwind data base) which I can debug on my side, in order to verify that I’d covered all scenarios? Thanks in advance.

    Best wishes,
    Nedyalko Nikolov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  14. Ben
    Ben avatar
    1 posts
    Member since:
    Oct 2010

    Posted 12 Apr 2012 Link to this post

    Was this still an issue in version 2011.2.920.1040?  I am getting an error when bound to an Observable Collection while all but one column is set to read only.  Handling the data error as described works for me but I am wondering if something else is wrong. I am also using cell style selectors but the error only presented itself when I moved from a read only grid to a having all but the one column read only. Stack Trace follows...

    Microsoft JScript runtime error: Unhandled Error in Silverlight Application
    Code: 4004   
    Category: ManagedRuntimeError      
    Message: System.NotImplementedException: The method or operation is not implemented.at Telerik.Windows.Controls.GridView.GridViewDataControl.RaiseDataErrorEvent(DataErrorEventArgs args)
       at Telerik.Windows.Controls.GridView.GridViewDataControl.CommitCurrentEdit(GridViewRow gridViewRow)
       at Telerik.Windows.Controls.GridView.GridViewDataControl.PerformRowEditEnded(GridViewCell currentCell)
       at Telerik.Windows.Controls.GridView.GridViewDataControl.CommitCellEdit(GridViewCell currentCell, Boolean isLeavingRow)
       at Telerik.Windows.Controls.GridView.GridViewDataControl.CommitEdit()
       at Telerik.Windows.Controls.GridView.GridViewCell.HandlePendingEdit()
       at Telerik.Windows.Controls.GridView.GridViewCell.HandlePendingEditOnLostFocus()
       at Telerik.Windows.Controls.GridView.GridViewCell.OnLostFocus(RoutedEventArgs e)
       at System.Windows.Controls.Control.OnLostFocus(Control ctrl, EventArgs e)
       at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)    
Back to Top
DevCraft banner