Skip to content

Commit

Permalink
[feat] ListField新增MaxWidth,用于指定超长隐藏文本的长度
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Dec 19, 2024
1 parent edd8677 commit 56e8b2c
Showing 1 changed file with 13 additions and 21 deletions.
34 changes: 13 additions & 21 deletions NewLife.CubeNC/ViewModels/ListField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ public class ListField : DataField
/// <summary>单元格样式</summary>
public String Class { get; set; }

/// <summary>最大宽度。用于指定超长隐藏文本的长度</summary>
public Int32 MaxWidth { get; set; }

///// <summary>头部链接。一般是排序</summary>
//public String HeaderUrl { get; set; }

Expand Down Expand Up @@ -350,28 +353,17 @@ public String GetTextClass(IModel data)
if (GetClass != null && data != null) return GetClass(data);

// 文本对齐方式
var tdClass = "";
switch (TextAlign)
var maxWidth = MaxWidth > 0 ? MaxWidth : 600;
var tdClass = TextAlign switch
{
case TextAligns.Default:
tdClass = "";
break;
case TextAligns.Left:
tdClass = "text-left";
break;
case TextAligns.Center:
tdClass = "text-center";
break;
case TextAligns.Right:
tdClass = "text-right";
break;
case TextAligns.Justify:
tdClass = "text-justify";
break;
case TextAligns.Nowrap:
tdClass = "text-nowrap;max-width:600px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;";
break;
}
TextAligns.Default => "",
TextAligns.Left => "text-left",
TextAligns.Center => "text-center",
TextAligns.Right => "text-right",
TextAligns.Justify => "text-justify",
TextAligns.Nowrap => $"text-nowrap;max-width:{maxWidth}px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;",
_ => "",
};
// 叠加样式
if (!Class.IsNullOrEmpty())
{
Expand Down

0 comments on commit 56e8b2c

Please sign in to comment.