zoukankan      html  css  js  c++  java
  • 信息系统开发平台OpenExpressApp - 支持列表分组(Group)

      在《内置支持的列表编辑方式》中介绍了OpenExpressApp内置的列表编辑方式。由于在列表显示过程中,经常会遇到需要分组显示的需求,所以OEA也内置了列表分组功能(暂时还不支持多对象树分组),与框架结合起来,完成这个功能更简单友好。本篇介绍一下OEA对列表分组的支持。

    界面

      设置分组后,AutoUI自动生成如下所示界面:每一组之上显示一条记录,左边为上下箭头,点击后可以展开和折叠分组的内容,右边显示分组依据属性和当前分组的条目数目。

    类库编写

      只需要在显示对象类型定义的BusinessObjectAttribute加上属性PropertyGroup,系统支持多个分组, 属性值为一个带分隔符‘;’的属性名称字符串列表,AutoUI会自动根据分组属性来构建列表界面,显示结果如上图所示,以下为代码片段:

        [BusinessObject(ModuleType = ModuleType.List, PropertyGroup= "ProjectName"), Label("清单查询")]
       
    public partial class SingleBq : GBusinessBase<SingleBq>
        {
            public string ProjectName
            {
                
    get
                {
                   
    return ProjectInfo.Name;
                }
            }
            
        }

    分组样式文件

      参考了《WPF - DataGrid 相关收集》中的WPF DataGrid Practical Examples,这个例子列举了很多微软DataGrid的使用,分组是参考Style完全版的那个页面中的Group样式而完成的。如果想学习这个,大家必须先对样式文件、WPF的分组有所了解,网上这类文章也很多,这里也不重复了。以下为样式:

    Code

    OpenExpressApp对分组支持的实现

    1. 元信息支持分组支持
          [AttributeUsage(AttributeTargets.Class)]
          
      public class BusinessObjectAttribute : Attribute
          {
              
      //默认分组
              public string PropertyGroup getset; }
              
          }
    2. 业务模型增加GroupDescriptions  
          /// <summary>
          
      /// 业务对象模型
          
      /// </summary>
          public class BusinessObjectInfo
          {
              
      /// 默认分组属性值
              public string[] GroupDescriptions;

              
      public BusinessObjectInfo(Type boType)
              {
                  
      this.BOType = boType;
                  BusinessObjectAttribute 
      = boType.GetSingleAttribute<BusinessObjectAttribute>();

                  
      if (!String.IsNullOrEmpty(BusinessObjectAttribute.PropertyGroup))
                      GroupDescriptions 
      = BusinessObjectAttribute.PropertyGroup.Split(';');
                  
              }
          }     

    3. 把上面的样式存为文件Resource.xaml在系统模块ExpressAppWPFModule的初始化方法中增加装载样式文件,代码如下:
                  resouceDic = Application.LoadComponent(new Uri("OpenExpressApp.Module.WPF;component/Resources/Resource.xaml", UriKind.Relative)) as ResourceDictionary;
                  Application.Current.Resources.MergedDictionaries.Insert(
      0, resouceDic);
    4. 增加以前的AutoUI.CreateListControl代码,设置GroupStyle
            public static object CreateListControl(Type boType, ListObjectView view)
              {
                  DataGrid dg 
      = new SelectionDataGrid()
                      {
                          CanUserAddRows 
      = false,
                          AutoGenerateColumns 
      = false,
                          VerticalGridLinesBrush 
      = new SolidColorBrush(Colors.Gray),
                          HorizontalGridLinesBrush 
      = new SolidColorBrush(Colors.Gray),
                      };
                  GroupStyle gs 
      = new GroupStyle();
                  gs.ContainerStyle 
      = Application.Current.TryFindResource("GroupContainerStyle"as Style;
                  dg.GroupStyle.Add(gs);
           ...
         }
    5. 修改ListEditor.OnSetData,设置collectionView.GroupDescriptions
              public virtual void OnSetData()
              {
                  ICollectionView collectionView 
      = CollectionViewSource.GetDefaultView(View.Data);
                  
      if (null != collectionView)
                  {
                      
      string[] groups = ApplicationModel.GetBusinessObjectInfo(BOType).GroupDescriptions;
                      
      if (null != groups)
                      {
                          
      foreach (string propertyName in groups)
                              collectionView.GroupDescriptions.Add(
      new PropertyGroupDescription(propertyName));
                      }
                  }
                  dg.ItemsSource 
      = collectionView;
              }

    更多内容: 开源信息系统开发平台之OpenExpressApp框架.pdf

  • 相关阅读:
    《楞严经四种清净明诲》 (转自学佛网:http://www.xuefo.net/nr/article56/559965.html)
    忏悔言情小说带来的意淫以及对治方法 (转自学佛网:http://www.xuefo.net/nr/article55/554935.html)
    一个80后妈妈的邪淫忏悔(转自学佛网:http://www.xuefo.net/nr/article55/551761.html)
    邪淫真正的可怕危害 (转自学佛网:http://www.xuefo.net/nr/article54/544414.html)
    净空法师详解《般若波罗蜜多心经》,转给有缘人
    净空法师主讲:净业三福【全2集】
    《阿含经》的思想
    佛教最早时期的根本经典 《阿含经》为何如此重要?
    弘一法师妙解《心经》
    读唯识三十颂讲话日记 原创: 李美君 那兰陀广场
  • 原文地址:https://www.cnblogs.com/zhoujg/p/1610700.html
Copyright © 2011-2022 走看看