EPR类企业管理系统

在我们现有系统基础上或全新开发,提供定制服务
为您的企业高效快速实施ERP,WMS,MES,CRM管理系统
全面管控物料仓库、销售业务、采购业务、仓库业务
生产过程、质量检验、组织架构、业务报表


定制
QQ:460-3528

开发
QQ群:3360-90194

源码
微信:136-3650-3721

如何:在仪表板上单击网格行时,打开详细视图

本主题描述了当用户单击使用仪表板模块创建的GridDashboardItem中的一行时如何调用详细视图。在调用的明细视图中,用户可以查看或编辑与单击的行相对应的业务对象。

WinForms示例

ASP.NET示例

using DevExpress.DashboardWeb;
using DevExpress.Data.Filtering;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.ExpressApp.Dashboards.Web;
using DevExpress.ExpressApp.Web;
using DevExpress.ExpressApp.Web.Templates;
using DevExpress.Persistent.Base;
using ShowDetailViewFromDashboard.Module.BusinessObjects;
using System;

namespace ShowDetailViewFromDashboard.Module.Web.Controllers
{
    public class WebShowDetailViewFromDashboardController : ObjectViewController<DetailView, IDashboardData>, IXafCallbackHandler
    {
        private const string HandlerName = "WebShowDetailViewFromDashboardController";
        private ParametrizedAction openDetailViewAction;

        protected override void OnActivated()
        {
            base.OnActivated();
            WebDashboardViewerViewItem dashboardViewerViewItem = View.FindItem("DashboardViewer") as WebDashboardViewerViewItem;
            if (dashboardViewerViewItem != null)
            {
                if (dashboardViewerViewItem.DashboardDesigner != null)
                {
                    CustomizeDashboardViewer(dashboardViewerViewItem.DashboardDesigner);
                }
                dashboardViewerViewItem.ControlCreated  = DashboardViewerViewItem_ControlCreated;
            }
        }
        private void DashboardViewerViewItem_ControlCreated(object sender, EventArgs e)
        {
            WebDashboardViewerViewItem dashboardViewerViewItem = sender as WebDashboardViewerViewItem;
            CustomizeDashboardViewer(dashboardViewerViewItem.DashboardDesigner);
        }
        private void CustomizeDashboardViewer(ASPxDashboard dashboardControl)
        {
            XafCallbackManager callbackManager = ((ICallbackManagerHolder)WebWindow.CurrentRequestPage).CallbackManager;
            callbackManager.RegisterHandler(HandlerName, this);
            string widgetScript = @"function getOid(s, e) {{
                                        function findMeasure(measure) {{
                                            return measure.DataMember === 'Oid';
                                        }}
                                        if (e.ItemName.includes('gridDashboardItem')) {{
                                             var itemData = e.GetData(),
                                                dataSlice = itemData.GetSlice(e.GetAxisPoint()),
                                                oidMeasure = dataSlice.GetMeasures().find(findMeasure).Id,
                                                measureValue = dataSlice.GetMeasureValue(oidMeasure);
                                                {0}
                                        }}
                                    }}";
            dashboardControl.ClientSideEvents.ItemClick = string.Format(widgetScript, callbackManager.GetScript(HandlerName, "measureValue.GetValue()"));
        }
        public void ProcessAction(string parameter)
        {
            openDetailViewAction.DoExecute(parameter);
        }
        private void OpenDetailViewAction_Execute(object sender, ParametrizedActionExecuteEventArgs e)
        {
            IObjectSpace objectSpace = Application.CreateObjectSpace(typeof(Contact));
            Contact contact = objectSpace.FindObject<Contact>(new BinaryOperator("Oid", e.ParameterCurrentValue.ToString()));
            if (contact != null)
            {
                e.ShowViewParameters.CreatedView = Application.CreateDetailView(objectSpace, contact, View);
            }
        }

        protected override void OnDeactivated()
        {
            WebDashboardViewerViewItem dashboardViewerViewItem = View.FindItem("DashboardViewer") as WebDashboardViewerViewItem;
            if (dashboardViewerViewItem != null)
            {
                dashboardViewerViewItem.ControlCreated -= DashboardViewerViewItem_ControlCreated;
            }
            base.OnDeactivated();
        }
        public WebShowDetailViewFromDashboardController()
        {
            openDetailViewAction = new ParametrizedAction(this, "Dashboard_OpenDetailView", "Dashboard", typeof(string));
            openDetailViewAction.Caption = "OpenDetailView";
            openDetailViewAction.SelectionDependencyType = SelectionDependencyType.RequireSingleObject;
            openDetailViewAction.Execute  = OpenDetailViewAction_Execute;
        }
    }
}

转载保留此链接,注明出处