-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(module: table): add RowClassName (#1031)
* feat(module: table): add row styling * docs: add RowClassName to docs * docs: add custom row style subtext * feat(module: table): add ExpandedRowClassName * remove RowClassName for expand row * add chinese doc Co-authored-by: ElderJames <shunjiey@hotmail.com>
- Loading branch information
1 parent
bf0edb4
commit 8f15f8f
Showing
4 changed files
with
82 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
site/AntBlazor.Docs/Demos/Components/Table/demo/CustomRowStyle.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
@using System.ComponentModel | ||
@using AntDesign.TableModels | ||
|
||
<Table TItem="Data" DataSource="@data" OnRowClick="OnRowClick" RowClassName="@(x => x.Data.RowClass)"> | ||
<Column @bind-Field="@context.Name"> | ||
<a>@context.Name</a> | ||
</Column> | ||
<Column @bind-Field="@context.Score"></Column> | ||
</Table> | ||
|
||
<style> | ||
.danger { | ||
background-color: #fff1f0; | ||
} | ||
</style> | ||
|
||
@code{ | ||
Data[] data = new Data[] | ||
{ | ||
new() | ||
{ | ||
Key = "1", | ||
Name = "John Brown", | ||
Score = 95, | ||
}, | ||
new() | ||
{ | ||
Key = "2", | ||
Name = "Jim Green", | ||
Score = 87, | ||
}, | ||
new() | ||
{ | ||
Key = "3", | ||
Name = "Joe Black", | ||
Score = 65, | ||
} | ||
}; | ||
|
||
public class Data | ||
{ | ||
[DisplayName("Key")] | ||
public string Key { get; set; } | ||
|
||
[DisplayName("Name")] | ||
public string Name { get; set; } | ||
|
||
[DisplayName("Score")] | ||
public int Score { get; set; } | ||
|
||
public string RowClass => Score < 70 ? "danger" : ""; | ||
} | ||
|
||
void OnRowClick(RowData<Data> row) | ||
{ | ||
Console.WriteLine($"row {row.Data.Key} was clicked"); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
site/AntBlazor.Docs/Demos/Components/Table/demo/custom-row-style.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
order: 22 | ||
title: | ||
en-US: Custom Row Styling | ||
zh-CN: 修改每行的样式 | ||
--- | ||
## en-US | ||
|
||
A solution for displaying custom styling on rows. | ||
> When you need to conditionally style rows based on the data provided. | ||
> The example highlights rows where score is < 70. | ||
## zh-CN | ||
|
||
可以使用 `RowClassName` 给特定的行设置 class。也可以用 `ExpandedRowClassName` 给特定的展开行设置 class。 |