zoukankan      html  css  js  c++  java
  • XAF中如何实现Action创建一个可以编辑外连接对象的detail

    在系统中有时候我们希望实现这样的创建操作,通过主数据创建一个关联表的对象,比如,通过库存表创建一个出入库单的对象并弹出一个窗体编辑给对象,在xaf中可以使用如下的代码实现:

    using System;
    using System.ComponentModel;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.Text;

    using DevExpress.ExpressApp;
    using DevExpress.ExpressApp.Actions;
    using DevExpress.Persistent.Base;
    using DevExpress.ExpressApp.SystemModule;
    namespace Tes.Module.INVE.Controllers
    {
       public partial class InveActionContriller : ViewController
        {
            private DetailView createdDetailView;
            //private InveActionContriller newController;
            public InveActionContriller()
            {
                InitializeComponent();
                RegisterActions(components);
                //this.TargetViewType = ViewType.ListView;
                
    //this.TargetViewNesting = Nesting.Nested;
                
    //this.TargetObjectType = typeof(Dy_Inventory);
                
            }
            private void actionCreateAdm_Execute(object sender, SimpleActionExecuteEventArgs e)
            {


                

                //Find an existing object.

                
    //Contact obj = os.FindObject<Contact>(CriteriaOperator.Parse("FirstName=?", "My Contact"));

                
    //Or create a new object.
                Contact obj = View.ObjectSpace.CreateObject<Contact>();

                obj.Dy_Materials = (Dy_Inventory)e.CurrentObject;

                //Save the changes if necessary.

                View.ObjectSpace.CommitChanges();
                IObjectSpace os = Application.CreateObjectSpace();

                e.ShowViewParameters.CreatedView = Application.CreateDetailView(os, os.GetObject(obj));
                //os = os.GetObject(obj);
                os.SetModified(os.GetObject(obj));
                //Specify various display settings.
                
                e.ShowViewParameters.TargetWindow = TargetWindow.NewModalWindow;

                e.ShowViewParameters.Context = TemplateContext.NestedFrame;
                
               
                e.ShowViewParameters.CreateAllControllers = true;

                //Provide standard dialog window functionality.

                DialogController dc = Application.CreateController<DialogController>();

                e.ShowViewParameters.Controllers.Add(dc);

         
                View.ObjectSpace.Refresh();
       
            }
        }
    }
  • 相关阅读:
    easyui-datagrid 编辑模式下保存数据,光标所在单元格无法保存。
    esayui datebox 系统日期之后禁止选择
    使用easy-TreeGrid完成角色权限设置;使用checkbox
    jquery easyui easyui-combobox 与easyui-textbox 取值赋值操作
    原生js table中点击操作按钮,获取相应行某列需要的值作为参数请求跳转
    excel 导出 兼容到ie (JavaScript)
    vue 路由导航重复跳转报错解决记录
    变量提升
    定时器轮播,轮播一次加载一张图;
    es7 es8 新加的特性。
  • 原文地址:https://www.cnblogs.com/ddlzq/p/2320538.html
Copyright © 2011-2022 走看看