Ways to Improve the Performance of ASP.NET Web Forms Office Module Editors(提高ASP.NET Web Forms办公模块编辑器性能的方法)
Rich Text Editor(富文本编辑器)
Display a Label Control Instead of ASPxRichEdit in View Mode(在查看模式下显示标签控件而非ASPxRichEdit)
The Label is a lightweight control that allows you to display HTML-formatted text. Use this control instead of ASPxRichEdit to reduce the View’s load time. Note that the Label and ASPxRichEdit controls show content differently, for example, Label does not support anchors.
标签是一种轻量级控件,允许您显示HTML格式的文本。使用此控件代替ASPxRichEdit可减少视图加载时间。请注意,标签和ASPxRichEdit控件显示内容的方式有所不同,例如,标签不支持锚点。
The following steps show how to replace the ASPxRichEdit with a Label in a Detail View in View mode:
以下步骤展示了如何在视图模式下的详细信息视图中用标签替换 ASPxRichEdit:
1*.In the ASP.NET Web Forms Module project, create a View Controller.*
在ASP.NET Web Forms模块项目中,创建一个视图控制器。
2*.In the overridden OnActivated method, access the WebRichTextViewModeController and deactivate it:*
在重写的 OnActivated 方法中,访问 WebRichTextViewModeController 并将其停用:
C#
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Office.Web;
// ...
public class ViewModeRichEditController : ObjectViewController<DetailView, Document> {
protected override void OnActivated() {
base.OnActivated();
Frame.GetController<WebRichTextViewModeController>()?.Active.SetItemValue("LabelMode", false);
}
protected override void OnDeactivated() {
base.OnDeactivated();
Frame.GetController<WebRichTextViewModeController>()?.Active.SetItemValue("LabelMode", true);
}
}
If you display this Detail View and a List View side-by-side, set the DetailView.ViewEditMode property to View. The following Controller demonstrates how to do this:
如果将此详细信息视图和列表视图并排显示,请将 DetailView.ViewEditMode 属性设置为“View”。以下控制器演示了如何执行此操作:
C#
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Web.SystemModule;
// ...
public class CustomMasterDetailModeController : WebMasterDetailModeController {
protected override void SetupViewEditMode(DetailView view) {
if(View.Id != "Document_ListView") {
base.SetupViewEditMode(view);
}
}
}
Hide the Ribbon Control in Edit Mode and Show it when Executing an Action(在编辑模式下隐藏功能区控件,并在执行操作时显示它)
Implement this approach when you display List and Detail Views side-by-side and want to hide the ASPxRichTextPropertyEditor’s Ribbon highlighted in the image below:
当你并排显示列表视图和详细信息视图,并且想要隐藏下图中突出显示的ASPxRichTextPropertyEditor的功能区时,采用此方法:
This approach also demonstrates how to create an Action that shows the Ribbon.
这种方法还展示了如何创建一个显示功能区的操作。
1*.In the ASP.NET Web Forms Module project, create a View Controller.*
在ASP.NET Web Forms模块项目中,创建一个视图控制器。
2.In the Controller’s constructor, create a SimpleAction and subscribe to its Execute event.
在控制器的构造函数中,创建一个简单操作并订阅其执行事件。
3*.In the overridden OnActivated method, set the MenuManagerType property to None for each ASPxRichTextPropertyEditor the View displays.*
在重写的 OnActivated 方法中,将视图显示的每个 ASPxRichTextPropertyEditor 的 MenuManagerType 属性设置为 None。
4.In the Action.Execute event handler, call the SetRibbonMode method to show a Ribbon control for each ASPxRichTextPropertyEditor the View displays.
在 Action.Execute 事件处理程序中,调用 SetRibbonMode 方法,为视图显示的每个 ASPxRichTextPropertyEditor 显示一个功能区控件。
C#
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.ExpressApp.Office.Web;
using DevExpress.Persistent.Base;
using DevExpress.Web.ASPxRichEdit;
// ...
public class ShowRibbonController : ObjectViewController<ListView, Document> {
public ShowRibbonController() {
SimpleAction showRibbonAction = new SimpleAction(this, "ShowRibbon", PredefinedCategory.Edit);
showRibbonAction.Execute += Action_Execute;
}
protected override void OnActivated() {
base.OnActivated();
foreach(var editor in View.EditView.GetItems<ASPxRichTextPropertyEditor>()) {
editor.MenuManagerType = WebMenuManagerType.None;
}
}
private void Action_Execute(object sender, SimpleActionExecuteEventArgs e) {
foreach(var editor in View.EditView.GetItems<ASPxRichTextPropertyEditor>()) {
editor.SetRibbonMode(RichEditRibbonMode.OneLineRibbon);
// optionally, you can display only the Home tab to speed up Ribbon loading
//editor.ASPxRichEditControl.RibbonTabs.ForEach(rt => { if(!(rt is DevExpress.Web.ASPxRichEdit.RERHomeTab)) rt.Visible = false; });
}
}
}
Spreadsheet Editor(电子表格编辑器)
Note
XAF does not support the Spreadsheet editor for ASP.NET Core Blazor applications.
XAF不支持ASP.NET Core Blazor应用程序的电子表格编辑器。
Enable Reading View Mode(启用阅读视图模式)
Enable Reading View Mode when you display large Spreadsheet documents.
在显示大型电子表格文档时,启用阅读视图模式。
1.In the ASP.NET Web Forms Module project, create a View Controller.
在ASP.NET Web Forms模块项目中,创建一个视图控制器。
2.In the overridden OnActivated method, access the ASPxSpreadsheetPropertyEditor’s control as described in How to: Access the Spreadsheet Control.
在重写的OnActivated方法中,按照“如何:访问电子表格控件”中所述访问ASPxSpreadsheetPropertyEditor的控件。
3*.Set ASPxSpreadsheet’s Mode property to Reading.*
将ASPxSpreadsheet的Mode属性设置为Reading。
C#
using System;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Office.Web;
using DevExpress.Web.ASPxSpreadsheet;
// ...
public class CustomASPxSpreadsheetController : ViewController<DetailView> {
protected override void OnActivated() {
base.OnActivated();
foreach (ASPxSpreadsheetPropertyEditor editor in View.GetItems<ASPxSpreadsheetPropertyEditor>()) {
if (editor.ASPxSpreadsheetControl != null) {
CustomizeSpreadsheetControl(editor.ASPxSpreadsheetControl);
}
else {
editor.ControlCreated += Editor_ControlCreated;
}
}
}
void Editor_ControlCreated(object sender, EventArgs e) {
ASPxSpreadsheet spreadsheet = ((ASPxSpreadsheetPropertyEditor)sender).ASPxSpreadsheetControl;
CustomizeSpreadsheetControl(spreadsheet);
}
void CustomizeSpreadsheetControl(ASPxSpreadsheet spreadsheetControl) {
spreadsheetControl.SettingsView.Mode = SpreadsheetViewMode.Reading;
}
}