@@ -343,6 +344,8 @@ private static RenderFragment RenderContent(this ITableColumn col, string? text)
internal static bool GetVisible(this ITableColumn col) => col.Visible ?? true;
+ internal static bool GetIgnoreExport(this ITableColumn col) => col.IgnoreWhenExport ?? false;
+
internal static bool GetShowCopyColumn(this ITableColumn col) => col.ShowCopyColumn ?? false;
internal static bool GetShowTips(this ITableColumn col) => col.ShowTips ?? false;
diff --git a/test/UnitTest/Attributes/AutoGenerateClassTest.cs b/test/UnitTest/Attributes/AutoGenerateClassTest.cs
index 575853f3252..fd005c21d55 100644
--- a/test/UnitTest/Attributes/AutoGenerateClassTest.cs
+++ b/test/UnitTest/Attributes/AutoGenerateClassTest.cs
@@ -71,7 +71,8 @@ public void AutoGenerateColumn_Ok()
HeaderTextWrap = true,
IsMarkupString = true,
- RequiredErrorMessage = "test"
+ RequiredErrorMessage = "test",
+ IgnoreWhenExport = true
};
Assert.Equal(1, attr.Order);
Assert.True(attr.Ignore);
@@ -105,6 +106,7 @@ public void AutoGenerateColumn_Ok()
Assert.True(attr.HeaderTextEllipsis);
Assert.Equal("test header tooltip", attr.HeaderTextTooltip);
Assert.True(attr.IsMarkupString);
+ Assert.True(attr.IgnoreWhenExport);
var attrInterface = (ITableColumn)attr;
attrInterface.ShowLabelTooltip = true;
diff --git a/test/UnitTest/Components/InternalTableColumnTest.cs b/test/UnitTest/Components/InternalTableColumnTest.cs
index 87a0af94e69..116bf2c17d0 100644
--- a/test/UnitTest/Components/InternalTableColumnTest.cs
+++ b/test/UnitTest/Components/InternalTableColumnTest.cs
@@ -86,6 +86,7 @@ public void InternalTableColumn_Ok()
SetValue("IsRequiredWhenAdd", true);
SetValue("IsRequiredWhenEdit", true);
SetValue("LookupService", null);
+ SetValue("IgnoreWhenExport", true);
void SetValue(string propertyName, object? val) => type!.GetProperty(propertyName)!.SetValue(instance, val);
}
diff --git a/test/UnitTest/Components/TableTest.cs b/test/UnitTest/Components/TableTest.cs
index 15020509840..17e862a42bd 100644
--- a/test/UnitTest/Components/TableTest.cs
+++ b/test/UnitTest/Components/TableTest.cs
@@ -8208,6 +8208,37 @@ public void IsMarkupString_Ok()
Assert.Equal("<div>Address - Test</div>
", cells[1].InnerHtml);
}
+ [Fact]
+ public void IgnoreWhenExport_Ok()
+ {
+ var items = new Foo[] { new() { Name = "Name", Address = "Address" } };
+ var cut = Context.RenderComponent(pb =>
+ {
+ pb.AddChildContent>(pb =>
+ {
+ pb.Add(a => a.RenderMode, TableRenderMode.Table);
+ pb.Add(a => a.Items, items);
+ pb.Add(a => a.TableColumns, foo => builder =>
+ {
+ builder.OpenComponent>(0);
+ builder.AddAttribute(1, "Field", "Name");
+ builder.AddAttribute(2, "FieldExpression", Utility.GenerateValueExpression(foo, "Name", typeof(string)));
+ builder.CloseComponent();
+
+ builder.OpenComponent>(0);
+ builder.AddAttribute(1, "Field", "Address");
+ builder.AddAttribute(2, "FieldExpression", Utility.GenerateValueExpression(foo, "Address", typeof(string)));
+ builder.AddAttribute(3, "IgnoreWhenExport", true);
+ builder.CloseComponent();
+ });
+ });
+ });
+
+ var table = cut.FindComponent>();
+ var columns = table.Instance.GetVisibleColumns();
+ Assert.Single(columns);
+ }
+
[Fact]
public void OnSelectedRows_Ok()
{
diff --git a/test/UnitTest/Utils/UtilityTest.cs b/test/UnitTest/Utils/UtilityTest.cs
index bb3340527e6..dd9a83a7ef9 100644
--- a/test/UnitTest/Utils/UtilityTest.cs
+++ b/test/UnitTest/Utils/UtilityTest.cs
@@ -581,12 +581,13 @@ public void GenerateTableColumns_Ok()
{
var cols = Utility.GetTableColumns(new InternalTableColumn[]
{
- new(nameof(Cat.Name), typeof(string)) { Text = "test-Name", LookupServiceData = true, IsVisibleWhenAdd = false, IsVisibleWhenEdit = false }
+ new(nameof(Cat.Name), typeof(string)) { Text = "test-Name", LookupServiceData = true, IsVisibleWhenAdd = false, IsVisibleWhenEdit = false, IgnoreWhenExport = true }
});
Assert.Equal(2, cols.Count());
Assert.Equal(true, cols.First().LookupServiceData);
Assert.False(cols.First().IsVisibleWhenAdd);
Assert.False(cols.First().IsVisibleWhenEdit);
+ Assert.True(cols.First().IgnoreWhenExport);
}
[Fact]