New Posts New Posts RSS Feed: Binding to Infragistics XamWebGrid with a FilterRow
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Binding to Infragistics XamWebGrid with a FilterRow

 Post Reply Post Reply
Author
btitular View Drop Down
Newbie
Newbie
Avatar

Joined: 08-Oct-2009
Location: CA
Posts: 20
Post Options Post Options   Quote btitular Quote  Post ReplyReply Direct Link To This Post Topic: Binding to Infragistics XamWebGrid with a FilterRow
    Posted: 25-Nov-2009 at 11:24am
I'm attempting to bind an ObservableCollection to an Infragistics XamWebGrid control (2009 v2) that has a filter row.
 
When the ObservableCollection contains objects dervied from my DomainModel entity class, and I attempt to set a column filter value via the UI, the VS2008 Just In Time Debugger fires with the following error message:
 
"Cannot call BeginEdit() on Deleted or Detached entities".
 
When I replace the ObservableCollection with a "simple" object (one not derived from a DomainModel class), the Infragistics control behaves correctly.
 
In searching Infragistics forums, I came across this:
 
When the FilterRow is being created  a blank row is created for underlying binding purposes,
 
The Infragistics web grid control has an event called DataObjectRequested that is triggered when a blank row for filtering is required. However, I'm lost as to how to attach the "blank row" object to the existing Entity Manager. I'm using Prism & MVVM I don't want to couple the View to my ViewModel.
 
Any suggestions?
Back to Top
btitular View Drop Down
Newbie
Newbie
Avatar

Joined: 08-Oct-2009
Location: CA
Posts: 20
Post Options Post Options   Quote btitular Quote  Post ReplyReply Direct Link To This Post Posted: 25-Nov-2009 at 1:30pm
Here's the stack trace when the exception is thrown:

---------------------------
Visual Studio Just-In-Time Debugger
---------------------------
An unhandled exception ('Unhandled Error in Silverlight Application
Code: 4004   
Category: ManagedRuntimeError      
Message: System.InvalidOperationException: Cannot call BeginEdit() on Deleted or Detached entities
   at IdeaBlade.EntityModel.EntityWrapper.System.ComponentModel.IEditableObject.BeginEdit()
   at Infragistics.Silverlight.Controls.XamWebGrid.EnterEditModeInternal(Row row, Cell cell)
   at Infragistics.Silverlight.Controls.XamWebGrid.EnterEditMode(CellBase cell)
   at Infragistics.Silverlight.Controls.XamWebGrid.SetActiveCell(CellBase cell, CellAlignment alignment, InvokeAction action, Boolean allowSelection, Boolean
setFocus, Boolean scrollIntoView)
   at Infragistics.Silverlight.Controls.XamWebGrid.SetActiveCell(CellBase cell, CellAlignment alignment, InvokeAction action, Boolean allowSelection, Boolean
scrollIntoView)
   at Infragistics.Silverlight.Controls.XamWebGrid.SetActiveCell(CellBase cell, CellAlignment alignment, InvokeAction action, Boolean allowSelection)
   at Infragistics.Silverlight.Controls.Cell.OnCellMouseDown(MouseEventArgs e)
   at Infragistics.Silverlight.Controls.XamWebGrid.c(Object A_0, MouseButtonEventArgs A_1)
   at System.Windows.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
   at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)    
') occurred in iexplore.exe [4980]. Just-In-Time debugging this exception failed with the following error: No installed debugger has Just-In-Time debugging
enabled. In Visual Studio, Just-In-Time debugging can be enabled from Tools/Options/Debugging/Just-In-Time.
Check the documentation index for 'Just-in-time debugging, errors' for more information.
---------------------------
OK  
---------------------------
Back to Top
btitular View Drop Down
Newbie
Newbie
Avatar

Joined: 08-Oct-2009
Location: CA
Posts: 20
Post Options Post Options   Quote btitular Quote  Post ReplyReply Direct Link To This Post Posted: 30-Nov-2009 at 7:33am
Response from Infragistics:
 
Hi, 

So, whenever something is about to go into edit mode, we check to see if the underlying data object implements IEditableObject. If it does, then we call the interface members. 

It appears that the  IdeaBlade.EntityModel.EntityWrapper doesn't like us calling the method on this object that represents the filter. 

Hard to say what they're exactly doing, however this isn't really something that we can handle on our end. 

Basically, for the filter row, we need a data object, so that we can filter, and display the correct editors for binding.  We do fire an event called DataObjectRequested, that allows you to override the object we use.  Perhaps you could provide an object that meets the criteria for the IdeaBlade object. 

-SteveZ

Back to Top
GregD View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 374
Post Options Post Options   Quote GregD Quote  Post ReplyReply Direct Link To This Post Posted: 30-Nov-2009 at 12:51pm
bitular:

It sounds like the problem is that the Infragistics grid attempts to call BeginEdit() on an entity that has never been added to the EntityManager and so has an EntityState of Detached. Currently DevForce doesn't support the calling of BeginEdit() on detached entities (as the error message notes).

I believe handling the DataObjectRequested event mentioned by Infragistics tech support will give you a workaround. In your handler, create an instance of the needed type and add it to the EntityManager before handing it to the grid. Be sure to keep track of the instance so you can remove it from the EntityManager when its work in facilitating filtering is done.

Back to Top
btitular View Drop Down
Newbie
Newbie
Avatar

Joined: 08-Oct-2009
Location: CA
Posts: 20
Post Options Post Options   Quote btitular Quote  Post ReplyReply Direct Link To This Post Posted: 09-Dec-2009 at 11:06am
Sorry, been putting out fires the last couple of days.
 
I did come up with a work around that solves this problem.
 
The Infragistics XamWebGrid needs a "blank" object that it uses to bind the filter row of the grid. In my case, I was binding a EntityObject to the grid for display purposes. When Infragistics creates the blank object, the filtering mechanism fails beacause the blank EntityObject is detached from an entity manager and can't go into an edit mode.
 
What I did was create another EntityManager in my view model, create a new EntityObject and added the EntityObject to that EntityManager. I then exposed the new EntityObject as a property (in my case, FilterRow) for the view model. In my XAML code behind, I then wired up the XamWebGrid.DataObjectReqested event to return the FilterRow property via the DataContext. The FilterRow object is used exclusively by the Infragistics filtering mechanism, so I don't have to worry about persisting the data. The only downside to this approach is that my view is now "aware" of my ViewModel since I had to wire up the DataObjectReqeusted event in my code behind.
 
At least for now, I have a functioning XamWebGrid with filtering capabilties.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down