namespace VberAdmin.Web.Models.Table; public class VmTableItem { public string FiledName { get; set; } public string DisplayName { get; set; } public string ClassName { get; set; } public string Formatter { get; set; } public string FormatterStr => string.IsNullOrEmpty(Formatter) ? "" : "data-formatter=\"" + Formatter + "\""; public string Align { get; set; } public int? Width { get; set; } public string WidthUnit { get; set; } public string WidthStr => Width != null ? $" data-width=\"{Width}{WidthUnit}\"" : ""; public bool IsSort { get; set; } public string Sort => IsSort ? " data-sortable=\"true\"" : ""; protected int TipLength { get; set; } public string Tip => TipLength > 0 ? $"data-tip=\"{TipLength}\"" : ""; public VmTableItem(string filedName, string displayName, string formatter = "", bool isSort = false, int tipLength = 0) { FiledName = filedName; DisplayName = displayName; Formatter = formatter; TipLength = tipLength; IsSort = isSort; Align = "center"; } public VmTableItem WithWidth(int width, string unit = "px") { Width = width; WidthUnit = unit; return this; } /// /// 超过指定字符将 被截取 用tip的方式显示 /// /// 默认 30个字符 /// public VmTableItem WithTip(int showLength = 30) { TipLength = showLength; return this; } public VmTableItem WithSort() { IsSort = true; return this; } public VmTableItem WithClassName(string className) { ClassName = className; return this; } public VmTableItem WithFormatter(string formatter) { Formatter = formatter; return this; } public VmTableItem WithRight() { Align = "right"; return this; } public VmTableItem WithLeft() { Align = "left"; return this; } }