Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,30 @@
<li>@((MarkupString)Localizer["SearchFormDescItem1"].Value)</li>
<li>@((MarkupString)Localizer["SearchFormDescItem2"].Value)</li>
</ul>
<div>@((MarkupString)Localizer["SearchFormTips"].Value)</div>
<p>@((MarkupString)Localizer["SearchFormTips"].Value)</p>
<p>@((MarkupString)Localizer["SearchFormItemMetadataListDesc"].Value)</p>
<ul class="ul-demo">
<li>@((MarkupString)Localizer["SearchFormItemMetadataListP1"].Value)</li>
<li>@((MarkupString)Localizer["SearchFormItemMetadataListP2"].Value)</li>
<li>@((MarkupString)Localizer["SearchFormItemMetadataListP3"].Value)</li>
<li>@((MarkupString)Localizer["SearchFormItemMetadataListP4"].Value)</li>
<li>@((MarkupString)Localizer["SearchFormItemMetadataListP5"].Value)</li>
<li>@((MarkupString)Localizer["SearchFormItemMetadataListP6"].Value)</li>
<li>@((MarkupString)Localizer["SearchFormItemMetadataListP7"].Value)</li>
<li>@((MarkupString)Localizer["SearchFormItemMetadataListP8"].Value)</li>
</ul>
<p>@((MarkupString)Localizer["SearchFormItemMetadataCustom"].Value)</p>
<Pre>public class CustomSelectTableSearchMetadata : StringSearchMetadata
{
public override RenderFragment? RenderContent() => builder =>
{
builder.OpenComponent&lt;SelectTable&lt;string&gt;&gt;(0);
builder.AddAttribute(10, nameof(SelectTable&lt;&gt;.Value), Value);
builder.AddAttribute(20, nameof(SelectTable&lt;&gt;.OnValueChanged), ValueChangedHandler);
Comment on lines +38 to +42
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code sample in this

 block is misleading/inaccurate for SelectTable. SelectTable<TItem> has a where TItem : class, new() constraint, so SelectTable<string> is not valid. Also the sample passes Value from StringSearchMetadata (a string?) into SelectTable<TItem>.Value (a TItem? from ValidateBase<TItem>), which won’t match typical SelectTable usage. Consider updating the sample to use a reference-type row model (e.g., Foo) and show how to map the selected row to the metadata filter value (or use a custom metadata type with a matching Value type).

Suggested change
public override RenderFragment? RenderContent() => builder =>
{
builder.OpenComponent&lt;SelectTable&lt;string&gt;&gt;(0);
builder.AddAttribute(10, nameof(SelectTable&lt;&gt;.Value), Value);
builder.AddAttribute(20, nameof(SelectTable&lt;&gt;.OnValueChanged), ValueChangedHandler);
// Selected row in the SelectTable (row model must be a reference type with a public parameterless constructor)
private Foo? SelectedFoo { get; set; }
public override RenderFragment? RenderContent() =&gt; builder =&gt;
{
builder.OpenComponent&lt;SelectTable&lt;Foo&gt;&gt;(0);
// Bind the table's selected row
builder.AddAttribute(10, nameof(SelectTable&lt;Foo&gt;.Value), SelectedFoo);
// When selection changes, update both SelectedFoo and the string-based metadata Value
builder.AddAttribute(20, nameof(SelectTable&lt;Foo&gt;.OnValueChanged),
EventCallback.Factory.Create&lt;Foo?&gt;(this, foo =&gt;
{
SelectedFoo = foo;
// Map the selected row to the search metadata's string Value (for example, use Name)
Value = foo?.Name;
ValueChangedHandler(Value);
}));

Copilot uses AI. Check for mistakes.
// ...
builder.CloseComponent();
};
}</Pre>
</section>
<Table TItem="Foo"
IsPagination="true" PageItemsSource="@PageItemsSource" SearchMode="SearchMode.Top"
Expand Down
12 changes: 11 additions & 1 deletion src/BootstrapBlazor.Server/Locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -5084,7 +5084,17 @@
"SelectedItemValue1": "Name1",
"SelectedItemValue2": "Name2",
"TablesSearchDesc": "Commonly used for single table maintenance, simple addition, deletion, modification, search, sorting, filtering, search and other common functions can be realized through attribute configuration, and very complex can be realized through the advanced usage of <code>Template</code> business needs functions",
"TablesSearchTitle": "Table Search"
"TablesSearchTitle": "Table Search",
"SearchFormItemMetadataListDesc": "The current version includes the following built-in <code>ISearchFormItemMetadata</code> implementations",
"SearchFormItemMetadataListP1": "<code>StringSearchMetadata</code> String search metadata, defaults to a contains relationship",
"SearchFormItemMetadataListP2": "<code>MultipleStringSearchMetadata</code> Multiple string search metadata, uses space-separated values to form multiple OR conditions, e.g. <b>condition1</b> <b>condition2</b> results in contains condition1 OR contains condition2",
"SearchFormItemMetadataListP3": "<code>NumberSearchMetadata</code> Number search metadata",
"SearchFormItemMetadataListP4": "<code>SelectSearchMetadata</code> Dropdown select search metadata",
"SearchFormItemMetadataListP5": "<code>MultipleSelectSearchMetadata</code> Multiple select dropdown search metadata",
"SearchFormItemMetadataListP6": "<code>DateTimeSearchMetadata</code> DateTime search metadata",
"SearchFormItemMetadataListP7": "<code>DateTimeRangeSearchMetadata</code> DateTime range search metadata",
"SearchFormItemMetadataListP8": "<code>CheckboxListSearchMetadata</code> Checkbox list search metadata",
"SearchFormItemMetadataCustom": "When the default search metadata above cannot meet your business requirements, for example when a dropdown needs to use the <code>SelectTable</code> component for display, you can inherit from a suitable search metadata base class to implement your own custom search metadata"
},
"BootstrapBlazor.Server.Components.Samples.Table.TablesSelection": {
"TablesSelectionCountText": "Count:{0}",
Expand Down
12 changes: 11 additions & 1 deletion src/BootstrapBlazor.Server/Locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -5084,7 +5084,17 @@
"SelectedItemValue1": "姓名1",
"SelectedItemValue2": "姓名2",
"TablesSearchDesc": "常用于单表维护,通过属性配置实现简单的增、删、改、查、排序、过滤、搜索等常用功能,通过 <code>Template</code> 的高级用法能实现非常复杂的业务需求功能",
"TablesSearchTitle": "Table 表格"
"TablesSearchTitle": "Table 表格",
"SearchFormItemMetadataListDesc": "当前版本内置 <code>ISearchFormItemMetadata</code> 实现类如下",
"SearchFormItemMetadataListP1": "<code>StringSearchMetadata</code> 字符串搜索元模型 默认是包含关系",
"SearchFormItemMetadataListP2": "<code>MultipleStringSearchMetadata</code> 多字符串搜索元模型默认使用空格分隔组成多个或者条件如 <b>条件1</b> <b>条件2</b> 最终形成 包含条件1 或者 包含条件2 的判定",
"SearchFormItemMetadataListP3": "<code>NumberSearchMetadata</code> 数字搜索元模型",
"SearchFormItemMetadataListP4": "<code>SelectSearchMetadata</code> 下拉选择搜索元模型",
"SearchFormItemMetadataListP5": "<code>MultipleSelectSearchMetadata</code> 多选下拉搜索元模型",
"SearchFormItemMetadataListP6": "<code>DateTimeSearchMetadata</code> 日期时间搜索元模型",
"SearchFormItemMetadataListP7": "<code>DateTimeRangeSearchMetadata</code> 日期时间范围搜索元模型",
"SearchFormItemMetadataListP8": "<code>CheckboxListSearchMetadata</code> 复选框列表搜索元模型",
"SearchFormItemMetadataCustom": "例如以上默认搜索元模型无法满足业务需求时,比如下拉框需要使用 <code>SelectTable</code> 组件进行展示,可以通过继承合适的搜索元模型基类自行实现一个自定义搜索元模型"
},
"BootstrapBlazor.Server.Components.Samples.Table.TablesSelection": {
"TablesSelectionCountText": "选中的行数:{0}",
Expand Down
Loading