mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-05 05:27:37 +08:00
118 lines
3.4 KiB
C#
118 lines
3.4 KiB
C#
@using System.ComponentModel
|
|
|
|
<Table DataSource="_data" TreeChildren="item=>item.Children">
|
|
<Selection CheckStrictly />
|
|
<Column @bind-Field="@context.Name" />
|
|
<Column @bind-Field="@context.Age" Width="12%" />
|
|
<Column @bind-Field="@context.Address" Width="30%" />
|
|
</Table>
|
|
|
|
@code {
|
|
Data[] _data;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await base.OnInitializedAsync();
|
|
|
|
await Task.Delay(500);
|
|
|
|
_data = data;
|
|
await InvokeAsync(StateHasChanged);
|
|
|
|
await Task.Delay(500);
|
|
|
|
_data[1].Children = new Data[]
|
|
{
|
|
new() {
|
|
Key = "21",
|
|
Name = "Jim Green",
|
|
Age = 42,
|
|
Address = "London No. 1 Lake Park",
|
|
},
|
|
};
|
|
}
|
|
|
|
Data[] data =
|
|
{
|
|
new() {
|
|
Key = "1",
|
|
Name = "John Brown sr.",
|
|
Age = 60,
|
|
Address = "New York No. 1 Lake Park",
|
|
Children = new Data[] {
|
|
new() {
|
|
Key = "11",
|
|
Name = "Jim Green",
|
|
Age = 42,
|
|
Address = "London No. 1 Lake Park",
|
|
},
|
|
new() {
|
|
Key= "12",
|
|
Name= "John Brown jr.",
|
|
Age=30,
|
|
Address= "New York No. 3 Lake Park",
|
|
Children=new Data[] {
|
|
new() {
|
|
Key= "121",
|
|
Name= "Jimmy Brown",
|
|
Age= 16,
|
|
Address= "New York No. 3 Lake Park",
|
|
},
|
|
}
|
|
},
|
|
new() {
|
|
Key= "13",
|
|
Name= "Jim Green sr.",
|
|
Age= 72,
|
|
Address= "London No. 1 Lake Park",
|
|
Children= new Data[]{
|
|
new() {
|
|
Key= "131",
|
|
Name= "Jim Green",
|
|
Age= 42,
|
|
Address= "London No. 2 Lake Park",
|
|
Children= new Data[] {
|
|
new() {
|
|
Key= "1311",
|
|
Name= "Jim Green jr.",
|
|
Age= 25,
|
|
Address= "London No. 3 Lake Park",
|
|
},
|
|
new() {
|
|
Key= "1312",
|
|
Name= "Jimmy Green sr.",
|
|
Age= 18,
|
|
Address= "London No. 4 Lake Park",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
new() {
|
|
Key = "2",
|
|
Name = "Joe Black",
|
|
Age = 32,
|
|
Address = "Sidney No. 1 Lake Park",
|
|
},
|
|
};
|
|
|
|
public class Data
|
|
{
|
|
[DisplayName("Key")]
|
|
public string Key { get; set; }
|
|
|
|
[DisplayName("Name")]
|
|
public string Name { get; set; }
|
|
|
|
[DisplayName("Age")]
|
|
public int Age { get; set; }
|
|
|
|
[DisplayName("Address")]
|
|
public string Address { get; set; }
|
|
|
|
public Data[] Children { get; set; }
|
|
}
|
|
}
|