BPM实例分享:玩转数据字典新技能-字典库排序

有童鞋问到字典库的排序问题这里简单介绍一个新技能

数据字典使用场景:请假流程里的请假类型,有病假、事假、调休等。
定义数据字典,并且在流程中使用SheetDropDownListSheetRadioButtonList展现由用户来选择,如图:

 

数据字典


使用SheetDropDownList,并且设置该控件的属性MasterDataCategory为“请假类型”,其代码可能如下:

<SheetControls:SheetDropDownListID="SheetDropDownList1"runat="server"DataField="请假类型"MasterDataCategory="请假类型"></SheetControls:SheetDropDownList>
在表单中显示的效果如下:

 

SheetDropDownList使用数据字典


表单设计器中使用

 


对于SheetDropDownListSheetCheckBoxList、SheetRadioButtonList控件,可以直接绑定数据字典显示选项。

数据字典固然方便,一不小心就建多了,字典库多了用起来也是有点麻烦。

 


下面教给大家一个简单实用的排序技能.
首先找到

 

\Portal\Admin\MvcDesigner\MvcDesignerService.ashx

 

下面的这个函数

 

#region 获取数据字典

   

        public void GetMasterDataCategory(HttpContext context)

        {

            List<string> items = new List<string>();

            Dictionary<string, string> table = OThinker.H3.WorkSheet.AppUtility.Engine.MetadataRepository.GetCategoryTable();

            foreach (string key in table.OrderBy(s=>s.Value).Select(x=>x.Key))

            {

                items.Add(table[key]);

            }

            context.Response.Write(JSSerializer.Serialize(items));

        }

   

        #endregion

 

把原来的 table.Keys 改成

 

table.OrderBy(s=>s.Value).Select(x=>x.Key)

 

可以任意改成喜欢的排序都可以。

posted @ 2017-03-30 14:43  小林谈开发  阅读(304)  评论(0编辑  收藏  举报