| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- 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;
- }
- /// <summary>
- /// 超过指定字符将 被截取 用tip的方式显示
- /// </summary>
- /// <param name="showLength">默认 30个字符</param>
- /// <returns></returns>
- 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;
- }
- }
|