using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
namespace WalkingTec.Mvvm.Core
{
///
/// GridColumnExtension
///
public static class GridColumnExtension
{
///
/// GetAllBottomColumns
///
///
///
///
public static IEnumerable> GetAllBottomColumns(this IEnumerable> self)
{
List> rv = new List>();
foreach (var item in self)
{
rv.AddRange(item.BottomChildren);
}
return rv;
}
///
/// Id
///
///
///
///
///
public static GridColumn SetId(this GridColumn self, string id) where T : TopBasePoco
{
self.Id = id;
return self;
}
///
/// 列头
///
///
///
///
///
public static GridColumn SetHeader(this GridColumn self, string header) where T : TopBasePoco
{
self.Title = header;
return self;
}
///
/// 本列是否需要分组
///
///
///
///
///
public static GridColumn SetNeedGroup(this GridColumn self, bool needGroup) where T : TopBasePoco
{
self.NeedGroup = needGroup;
return self;
}
public static GridColumn SetLocked(this GridColumn self, bool locked) where T : TopBasePoco
{
self.IsLocked = locked;
return self;
}
public static GridColumn SetSortable(this GridColumn self, bool sortable = false) where T : TopBasePoco
{
self.Sortable = sortable;
return self;
}
///
/// 列宽
///
///
///
///
///
public static GridColumn SetWidth(this GridColumn self, int? width) where T : TopBasePoco
{
self.Width = width;
return self;
}
///
/// 是否允许换行
///
///
///
///
///
public static GridColumn SetAllowMultiLine(this GridColumn self, bool allowMultiLine) where T : TopBasePoco
{
self.AllowMultiLine = allowMultiLine;
return self;
}
///
/// 设置某列是否应该尽量充满
///
///
///
///
///
public static GridColumn SetFlex(this GridColumn self, int? flex) where T : TopBasePoco
{
self.Flex = flex;
return self;
}
/////
///// 时间与数字类型Format
/////
/////
/////
/////
/////
//public static GridColumn SetFormat(this GridColumn self, string format) where T : TopBasePoco
//{
// self.StringFormat = format;
// return self;
//}
///
/// 列内容的格式化函数
///
///
///
///
///
public static GridColumn SetFormat(this GridColumn self, ColumnFormatCallBack format) where T : TopBasePoco
{
self.Format = format;
return self;
}
///
/// 计算列值的表达式
///
///
///
///
///
public static GridColumn SetColumnExp(this GridColumn self, Expression> columnExp) where T : TopBasePoco
{
self.ColumnExp = columnExp;
return self;
}
///
/// 子列
///
///
///
///
///
public static GridColumn SetChildren(this GridColumn self, params GridColumn[] childrens) where T : TopBasePoco
{
List> temp = new List>();
if (self.Children == null)
{
temp = new List>();
}
else
{
temp = self.Children.Cast>().ToList();
}
temp.AddRange(childrens);
self.Children = temp;
return self;
}
///
/// 本列前景色函数
///
///
///
///
///
public static GridColumn SetForeGroundFunc(this GridColumn self, Func foreGroundFunc) where T : TopBasePoco
{
self.ForeGroundFunc = foreGroundFunc;
return self;
}
///
/// 本列背景色函数
///
///
///
///
///
public static GridColumn SetBackGroundFunc(this GridColumn self, Func backGroundFunc) where T : TopBasePoco
{
self.BackGroundFunc = backGroundFunc;
return self;
}
///
/// 设置本列是否显示汇总
///
///
///
/// 是否显示
///
public static GridColumn SetShowTotal(this GridColumn self, bool show = true) where T : TopBasePoco
{
self.ShowTotal = show;
return self;
}
///
/// 设置禁止导出此列数据
///
///
///
///
public static GridColumn SetDisableExport(this GridColumn self) where T : TopBasePoco
{
self.DisableExport = true;
return self;
}
}
}