List View Edit Modes
- 6 min to read
The default method of editing object properties in WinForms XAF applications is to choose an object from the List View, invoke the Detail View in a separate window, edit properties and save an object. In ASP.NET Web XAF applications, when you click an object in a List View, a corresponding Detail View is first opened in View mode. Then, you can use the SwitchToEditMode action to switch the Detail View to the Edit mode. However, the default functionality can be extended. For instance, properties displayed in a List View can be edited in place, as in a spreadsheet editor. This topic describes additional functionality available to XAF ASP.NET and WinForms applications, and explains how it can be enabled. Mobile applications does not support in-place editing.
Common Functionality Available in WinForms and ASP.NET Applications
The following image illustrates an editable List View in WinForms and ASP.NET applications.
In a WinForms XAF application, an existing object can be edited by selecting a row and clicking the property cell, and a new object can be added by clicking the new item row. In an ASP.NET XAF application, an existing object can be edited and a new object can be created by clicking the Edit () and New () buttons located in a row. To enable this functionality, perform the following steps.
- Invoke the Model Editor, expand the Views and navigate to the child node corresponding to the appropriate List View.
- To enable in-place editing in the selected List View, set the IModelView.AllowEdit property to True.
- To allow end-users to create new objects directly in the List View, set the IModelView.AllowNew property to True and the IModelListViewNewItemRow.NewItemRowPosition property to Top or Bottom. The new item row will be displayed at the top or at the bottom of the List View, respectively.
Split Layout (The MasterDetailMode Property)
When the split layout is activated, the Detail View is displayed together with the List View in the same window. The detail View displays the currently selected object properties. The Detail View content changes dynamically, depending on the current object focused in the List View. The following images illustrate the split layout.
To enable the split layout for a specific List View, perform the following steps.
- Invoke the Model Editor, expand the Views and navigate to the child node corresponding to the desired List View.
- Set the IModelListView.MasterDetailMode property to ListViewAndDetailView.
- The Detail View can be displayed either to the right or below the List View. Navigate to the SplitLayout child node, and set the IModelSplitLayout.Direction property to either Horizontal or to Vertical.
An object can have several Detail Views available. The IModelListView.MasterDetailView property allows you to specify the Detail View that will represent the object currently selected in the List View. If this property value is empty, the IModelListView.DetailView value is used. If both MasterDetailView and DetailView properties are unspecified, then the IModelClass.DefaultDetailView value specified for the current object type is used.
WinForms Specific Functionality
Commit Changes Automatically
The WinForms application default behavior is to display the confirmation dialog if an end-user focuses another element in the window after editing a cell (either using the in-place editor or using the Detail View).
The changes made in an editable List View can be saved automatically, without confirmation, when selecting another object in the View or focusing another element in the window. Use the ModificationsController.ModificationsHandlingMode and ModificationsController.ModificationsCheckingMode properties to change the desired behavior for editable List Views.
ASP.NET Specific Functionality
In-place Editing Customization (The InlineEditMode Property)
In addition to the standard Edit Action, ASP.NET Web XAF applications have a special InlineEdit Action. Although this Action belongs to the standard RecordEdit category, it is not displayed on the main toolbar. Instead, it is displayed in a List Editor's context menu and processed by the List Editor internally. To customize the in-place edit mode in an ASP.NET application, use the IModelListViewWeb.InlineEditMode property of a Views | <ListView> node.
This property is considered by the ASPxGridListEditor when the IModelView.AllowEdit property is set to True. The following table explains and illustrates possible values of the InlineEditMode property.
|EditForm||Cell values are edited with the Edit Form. The data row whose values are currently being edited is not displayed.|
|EditFormAndDisplayRow||Cell values are edited with the Edit Form. The data row whose values are currently being edited is displayed above the Edit Form.|
|Inline||Cell values are edited within the Inline Edit Row.|
|PopupEditForm||Cell values are edited with the Popup Edit Form.|
|Batch||Enables the Batch Edit Mode. The data rows whose values are currently being edited are saved only on clicking the Save changes button. Unlike other modes, in this mode you can edit multiple rows and then click Save changes to save all modified objects at once.|
The Batch Edit Mode has certain specificities:
- The Detail View is not invoked when a user clicks a row.
- New rows cannot be edited and saved if the ASPxGridListEditor.UseASPxGridViewDataSpecificColumns property is set to false.
- Several data types cannot be edited: images, references, criteria, file attachments. However, you can manually make the reference property editable as described in the How to: Edit a Reference Property in the Batch Edit Mode topic.
- Initial property values for new objects are passed to the client once when the grid control is created, and not updated each time when you create objects using the New Command Item.
- Cell templates (see ColumnBase.CellTemplate) are not used when this mode is enabled, and thus property editors are not used for standard column types either. To customize cell editors in this case, use native ASPxGridView capabilities, i.e., configure its column properties.
Collection Properties Edit Modes
The eXpress Application Framework provides two edit modes for collection properties in an ASP.NET Web application.
By default, collection properties are always displayed in a Detail View, but can only be modified when the Detail View is in edit mode.
Collection properties are not displayed in Edit mode. Instead, they are displayed and can be modified in View mode.
The mode can be specified globally using the WebApplication.CollectionsEditMode property (see How to: Hide Collection Properties in an Edit Mode Detail View for an ASP.NET Application). To change the mode for an individual List View, use the IModelDetailViewWeb.CollectionsEditMode property in the Model Editor.