Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Visible parameter to TableColumn #19435

Merged
merged 2 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/en/UI/Blazor/Data-Table-Column-Extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ This section explains how to customize data table columns using the properties i
* `Sortable`: A boolean field indicating whether the column is sortable or not.
* `DisplayFormat`: You can specify a custom format for the column.
* `DisplayFormatProvider` : You can provide a custom `IFormatProvider` for the column. Default value is `CultureInfo.CurrentCulture`.
* `Visible`: A boolean field indicating whether the column is visible or not.

## Rendering Custom Components In The Data Table Columns

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public class TableColumn
public Func<object, string>? ValueConverter { get; set; }

public bool Sortable { get; set; }

public bool Visible { get; set; } = true;

public TableColumn()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@
{
@if (column.ValueConverter == null)
{
<DataGridColumn TItem="TItem" Field="@column.Data" Caption="@column.Title" Sortable="@column.Sortable" DisplayFormat="@column.DisplayFormat" DisplayFormatProvider="@column.DisplayFormatProvider" >
<DataGridColumn TItem="TItem" Field="@column.Data" Caption="@column.Title" Sortable="@column.Sortable" DisplayFormat="@column.DisplayFormat" DisplayFormatProvider="@column.DisplayFormatProvider" Displayable="column.Visible" >
<DisplayTemplate>
@RenderCustomTableColumnComponent(column.Component, context)
</DisplayTemplate>
</DataGridColumn>
}
else
{
<DataGridColumn TItem="TItem" Field="@column.Data" Caption="@column.Title" Sortable="@column.Sortable">
<DataGridColumn TItem="TItem" Field="@column.Data" Caption="@column.Title" Sortable="@column.Sortable" Displayable="column.Visible">
<DisplayTemplate>
@RenderCustomTableColumnComponent(column.Component, context)
</DisplayTemplate>
Expand All @@ -100,14 +100,16 @@
Caption="@column.Title"
Sortable="@column.Sortable"
DisplayFormat="@column.DisplayFormat"
DisplayFormatProvider="@column.DisplayFormatProvider"/>
DisplayFormatProvider="@column.DisplayFormatProvider"
Displayable="column.Visible"/>
}
else
{
<DataGridColumn TItem="TItem"
Field="@column.Data"
Caption="@column.Title"
Sortable="@column.Sortable">
Sortable="@column.Sortable"
Displayable="column.Visible">
<DisplayTemplate>
@(GetConvertedFieldValue(context, column))
</DisplayTemplate>
Expand All @@ -116,7 +118,7 @@
}
else
{
<DataGridColumn TItem="TItem" Field="@nameof(IHasExtraProperties.ExtraProperties)" SortField="@column.PropertyName" Caption="@column.Title">
<DataGridColumn TItem="TItem" Field="@nameof(IHasExtraProperties.ExtraProperties)" SortField="@column.PropertyName" Caption="@column.Title" Displayable="column.Visible">
<DisplayTemplate>
@{
var entity = context as IHasExtraProperties;
Expand Down
Loading