mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-02 03:57:38 +08:00
feat(module: select): support table select (#3693)
This commit is contained in:
parent
c31fd48874
commit
e68b3a0446
@ -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);
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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",
|
||||
}
|
||||
};
|
||||
}
|
@ -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.
|
Loading…
Reference in New Issue
Block a user