Hello,
i create the property editors for my custom EditForm as follows:
IModelViewItems modelViewItems = Application.FindModelClass(ObjectType).DefaultDetailView.Items;
IModelMemberViewItem mvi1 = (IModelMemberViewItem)modelViewItems["Brennstoff"];
ViewItem pe1 = (ViewItem)Application.EditorFactory.CreateDetailViewEditor(false, mvi1, ObjectType, Application, ObjectSpace);
pe1.CurrentObject = MyCurrentObject;
((ASPxLookupPropertyEditor)pe1).ViewEditMode = ViewEditMode.Edit;
pe1.CreateControl();
((ASPxLookupPropertyEditor)pe1).SetControlId("Brennstoff");
IModelMemberViewItem mvi2 = (IModelMemberViewItem)modelViewItems["Art"];
ViewItem pe2 = (ViewItem)Application.EditorFactory.CreateDetailViewEditor(false, mvi2, ObjectType, Application, ObjectSpace);
pe2.CurrentObject = MyCurrentObject;
((WebPropertyEditor)pe2).ViewEditMode = ViewEditMode.Edit;
pe2.CreateControl();
…
IModelMemberViewItem mvi6 = (IModelMemberViewItem)modelViewItems["MwSt"];
ViewItem pe6 = (ViewItem)Application.EditorFactory.CreateDetailViewEditor(false, mvi6, ObjectType, Application, ObjectSpace);
pe6.CurrentObject = MyCurrentObject;
((ASPxLookupPropertyEditor)pe6).ViewEditMode = ViewEditMode.Edit;
pe6.CreateControl();
((ASPxLookupPropertyEditor)pe6).SetControlId("MwSt");
…
tr1.Cells[1].Controls.Add((Control)pe1.Control);
tr2.Cells[1].Controls.Add((Control)pe2.Control);
tr3.Cells[1].Controls.Add((Control)pe3.Control);
tr1.Cells[3].Controls.Add((Control)pe4.Control);
tr2.Cells[3].Controls.Add((Control)pe5.Control);
tr3.Cells[3].Controls.Add((Control)pe6.Control);
The edit form is displayed and saving and cancel works.
Please find an screenshot attached.
BUT if the form is not closed before selecting a another menu item of the applications main menu the following error occurs:
Type: ObjectDisposedException
Message: Cannot access a disposed object.
Object name: 'DevExpress.ExpressApp.LookupEditPropertyCollectionSource'.
Data: 0 entries
Stack trace:
at DevExpress.ExpressApp.CollectionSourceBase.SetObjectSpace(IObjectSpace objectSpace)
at DevExpress.ExpressApp.CollectionSourceBase…ctor(IObjectSpace objectSpace, Boolean isServerMode, CollectionSourceMode mode)
at DevExpress.ExpressApp.PropertyCollectionSource…ctor(IObjectSpace objectSpace, Type masterObjectType, Object masterObject, IMemberInfo memberInfo, Boolean isServerMode, CollectionSourceMode mode)
at DevExpress.ExpressApp.PropertyCollectionSource…ctor(IObjectSpace objectSpace, Type masterObjectType, Object masterObject, IMemberInfo memberInfo, CollectionSourceMode mode)
at DevExpress.ExpressApp.LookupEditPropertyCollectionSource…ctor(IObjectSpace objectSpace, Type masterObjectType, Object masterObject, IMemberInfo memberDescriptor, DataSourcePropertyIsNullMode dataSourcePropertyIsNullMode, String dataSourcePropertyIsNullCriteria, CollectionSourceMode collectionSourceMode)
at DevExpress.ExpressApp.Editors.LookupEditorHelper.CreateCollectionSourceCore(Object editingObject, Boolean strictlyClientMode)
at DevExpress.ExpressApp.Editors.LookupEditorHelper.CanFilterDataSource(CollectionSourceBase listViewCollectionSource, Object editingObject)
at DevExpress.ExpressApp.Web.Editors.ASPx.ASPxLookupPropertyEditor.UseFindEdit()
at DevExpress.ExpressApp.Web.Editors.ASPx.ASPxLookupPropertyEditor.UpdateControlsVisibility()
at DevExpress.ExpressApp.Web.Editors.ASPx.ASPxLookupPropertyEditor.ReadEditModeValueCore()
at DevExpress.ExpressApp.Web.Editors.WebPropertyEditor.ReadEditModeValue()
at DevExpress.ExpressApp.Web.Editors.WebPropertyEditor.ReadValueCore()
at DevExpress.ExpressApp.Editors.PropertyEditor.ReadValue()
at DevExpress.ExpressApp.Web.Editors.WebPropertyEditor.CallbackManager_PreRenderInternal(Object sender, EventArgs e)
at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
at DevExpress.ExpressApp.Web.Templates.XafCallbackManager.OnPreRenderInternal()
at DevExpress.ExpressApp.Web.Templates.XafCallbackManager.callbackControl_Callback(Object source, CallbackEventArgs e)
at DevExpress.Web.ASPxCallback.ASPxCallback.OnCallback(CallbackEventArgs e)
at DevExpress.Web.ASPxCallback.ASPxCallback.RaiseCallbackEvent(String eventArgument)
at DevExpress.Web.ASPxClasses.ASPxWebControl.System.Web.UI.ICallbackEventHandler.RaiseCallbackEvent(String eventArgument)
InnerException is null
Auto generated forms will work so this error has to be dedicated to the way the PropertyEditors are created.
I need a serious help yet.
I spend weeks and day for day to get a custom EditForm which will work as user can expect.
There is no documentation and no complete example online.
My code you find above results on communication with your team.
It can not be that with every step forward there will be a new wall i crash in.
Thank you.
Jürgen
Hello,
the reason for the error must be assigned to the ObjecctSpace.
I found out, that i have to generate the controls for EditFormTemplate in a new ObjectSpace and not in the Views ObjectSpace as i found in a posted example for the cell Editors of the DataItemTemplate (http://www.devexpress.com/Support/Center/p/Q432101.aspx)
Thanks
Jürgen
Hello Juergen,
Thank you for contacting us.
I have already warned you in your other ticket (Q434251) that we have not tested this particular scenario in XAF and it may lead to other issues:
"…we have not tested this scenario in XAF. It may also lead to further errors like the one you encountered. Due to this, I am afraid we will not be able to assist you further in this case."
There, I also mentioned that this API is undocumented and therefore, you use it at your own risk.
Honestly, I am not exactly sure why this error occurs after selecting a menu item, because I could not find anything wrong with the code you posted.
My best advice to you at this stage is to debug the XAF source code to be able to step into it and see exactly why it led to this error. This is general and the most effective advice for situations when you are trying to do something unsupported by default, and when you make use of an undocumented API or getting strange errors.
PS.
For some reason, I feel that calling the ASPxGridView.CancelEdit method somewhere in the overridden OnDeactivated method of a ViewController for this problematic ListView may help you resolve the issue. Based on the call stack the edit form (and its disposed of controls and entities) is still being accessed on a callback initiated by choosing another menu item. You can also use the solution you found, if it meets your needs.
Hello Dennis,
thank you for your suggestions.
To create the controls in an seperate objectspace seems not to impact the functionality of the grid or of the edit template.
The application runs stable and i could not detect any side effect until yet.
BUT as you will find when you read the error message above: … it is the LookupPropertyEditor again which will cause the error.
Perhaps i have to set some parameters or i have to do the allocation of the business object in an other way. I found some helper functions but no documentation how to use and when to use.
Can you give me the tip where i can exactly find the code for building the auto generated template for the edit view.
Thank you.
Jürgen
>>
Can you give me the tip where i can exactly find the code for building the auto generated template for the edit view.
<<
I am afraid there is no single place for this code. It is spread across many source files. First, I suggest you look at the DataItemTemplate class: …\DevExpress.ExpressApp.Web\Editors\ASPx\ASPxDataItemTemplate.cs and its use in …\XAF\DevExpress.ExpressApp.Web\Editors\ComplexWebListEditor.cs, …\DevExpress.ExpressApp.Web\Editors\ASPx\GridListEditor\ASPxGridListEditor.cs file and other files. I hope this helps.