feat(module: select): support table select (#3693)

This commit is contained in:
James Yeung 2024-02-22 23:11:23 +08:00 committed by GitHub
parent c31fd48874
commit e68b3a0446
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 84 additions and 5 deletions

View File

@ -51,7 +51,7 @@ namespace AntDesign
protected SelectContent<TItemValue, TItem> _selectContent;
protected IEnumerable<TItemValue> _selectedValues;
protected TItemValue[] _selectedValues;
protected Action<TItem, string> _setLabel;
@ -267,12 +267,12 @@ namespace AntDesign
return;
}
_selectedValues = value;
_selectedValues = value.ToArray();
_ = OnValuesChangeAsync(value);
}
else
{
_selectedValues = value;
_selectedValues = value.ToArray();
_ = OnValuesChangeAsync(value);
}

View File

@ -170,11 +170,11 @@ namespace AntDesign
if (!hasChanged)
return;
_selectedValues = value;
_selectedValues = value.ToArray();
}
else if (value != null && _selectedValues == null)
{
_selectedValues = value;
_selectedValues = value.ToArray();
}
else if (value == null && _selectedValues != null)
{

View File

@ -0,0 +1,65 @@
@using AntDesign.Docs.Services
<Select Style="width: 200px;"
ValueProperty="c=>c"
LabelProperty="c=>c.Name"
DataSource="data"
@bind-Values="@selectedRows"
Mode="multiple"
DropdownMatchSelectWidth="false">
<DropdownRender>
<Table @ref="table" DataSource="@data" @bind-SelectedRows="selectedRows" RowKey="x=>x.Name">
<ColumnDefinitions Context="ctx">
<Selection Key="@ctx.Name" />
<PropertyColumn Property="c=>c.Name">
<a>@ctx.Name</a>
</PropertyColumn>
<PropertyColumn Property="c=>c.Age"/>
<PropertyColumn Property="c=>c.Address"/>
</ColumnDefinitions>
</Table>
</DropdownRender>
</Select>
@inject IconListService _iconListService
@code
{
ITable table;
IEnumerable<Column> selectedRows=[];
class Column
{
public string Name { get; set; }
public int Age { get; set; }
public string Address { get; set; }
}
Column[] data =
{
new Column()
{
Name = "John Brown",
Age = 32,
Address = "New York No. 1 Lake Park",
},
new Column()
{
Name = "Jim Green",
Age = 42,
Address = "London No. 1 Lake Park",
},
new Column()
{
Name = "Joe Black",
Age = 32,
Address = "Sidney No. 1 Lake Park",
},
new Column()
{
Name = "Disabled User",
Age = 99,
Address = "Sidney No. 1 Lake Park",
}
};
}

View File

@ -0,0 +1,14 @@
---
order: 23
title:
zh-CN: 列表选择器
en-US: Table Select
---
## zh-CN
利用自定义下拉模板实现列表选择器。
## en-US
Implement a list selector with a custom dropdown render.