Data item templates are not always required. Without unnecessary templates our web list editors will be rendered faster, especially in IE that has low tables rendering speed.
Here is some example code:
C#using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Web.Editors.ASPx;
using DevExpress.Web.ASPxGridView;
namespace YourSolutionName.Module.Web {
public class RemoveCustomTemplatesFromGridColumns : ViewController<ListView> {
ASPxGridListEditor gridListEditor;
protected override void OnActivated() {
base.OnActivated();
gridListEditor = View.Editor as ASPxGridListEditor;
if(gridListEditor != null) {
gridListEditor.EnableGroupTemplate = false;
}
}
protected override void OnDeactivated() {
gridListEditor = null;
base.OnDeactivated();
}
protected override void OnViewControlsCreated() {
base.OnViewControlsCreated();
if(gridListEditor != null) {
foreach(GridViewColumn column in gridListEditor.Grid.Columns) {
if(column is GridViewDataColumn && !(column is GridViewDataActionColumn)) {
((GridViewDataColumn)column).DataItemTemplate = null;
((GridViewDataColumn)column).EditItemTemplate = null;
}
}
}
}
}
}
Take special note that XAF provides custom data and edt item and group ITemplate objects as part of the PropertyEditor creation for each column to deliver a generic way to control data validation, formatting, localization and other XAF features. They will be lost when this code is used, but perhaps you do not need them in certain scenarios.
Alternatively, to improve performance of large grids with a lot of records and columns you can do the following:
- Create a new ListEditor using the ASPxGridView control as it is described in the How to: Implement an ASP.NET Web List Editor Using a Custom Control.
- Implement a custom ViewItem based on a user control with the same ASPxGridView and show a dashboard View from the navigation as it is demonstrated at How to show custom forms and controls in XAF (Example).
Options #1-2 are pretty similar and basically vary by the container where a pure ASPxGridView will reside.
See Also:
ASPxGridView very slow with 30 properties
Group By panel problem
UPDATE:
Starting from version 12.1, to have a greater performance (a dozen times better under certain circumstances) in grids with grouped columns you can set the EnableGroupTemplate property of ASPxGridListEditor to False before the editor's controls are created (e.g. during the ViewController's activation).
Take special note that setting this property will completely remove templates from reference and enumeration properties so that they will be displayed as plain text using standard ASPxGridView capabilities (see the attached screenshot - as you see there is no hyper link for an object shown in the group).
So, this solution may be not suitable if you require localized values for enumerations gotten from the application model for more than one language.
Of course, this is not the final solution and we will certainly explore other solutions to decrease page loading and keep the standard rich functionality.
Thanks,
Dennis