学习020-01-04 Ways to Improve the Performance of ASP.NET Web Forms Office Module Editors(提高ASP.NET Web

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;
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

汤姆•猫

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值