!2376 doc(#I4SKWJ): update sample code for AutoFill

* doc: 更新 AutoFill 组件示例文档
This commit is contained in:
Argo 2022-02-01 06:34:37 +00:00
parent abbdc4b931
commit 0e1b866955

View File

@ -45,7 +45,7 @@ partial class AutoFills
return Task.CompletedTask;
}
private string OnGetDisplayText(Foo foo) => foo.Name ?? "";
private static string OnGetDisplayText(Foo foo) => foo.Name ?? "";
private Task<IEnumerable<Foo>> OnCustomFilter(string searchText)
{
@ -57,71 +57,87 @@ partial class AutoFills
/// 获得属性方法
/// </summary>
/// <returns></returns>
private IEnumerable<AttributeItem> GetAttributes() => new[]
private static IEnumerable<AttributeItem> GetAttributes() => new[]
{
// TODO: 移动到数据库中
new AttributeItem() {
Name = "DisplayCount",
Description = "匹配数据时显示的数量",
Type = "int",
ValueList = " — ",
DefaultValue = " — "
},
new AttributeItem() {
Name = "NoDataTip",
Description = "无匹配数据时显示提示信息",
Type = "string",
ValueList = " — ",
DefaultValue = "无匹配数据"
},
new AttributeItem() {
Name = "IgnoreCase",
Description = "匹配时是否忽略大小写",
Type = "bool",
ValueList = "true/false",
DefaultValue = "true"
},
new AttributeItem() {
Name = "IsLikeMatch",
Description = "是否开启模糊查询",
Type = "bool",
ValueList = "true/false",
DefaultValue = "false"
},
new AttributeItem() {
Name = "Items",
Description = "组件数据集合",
Type = "IEnumerable<TValue>",
ValueList = " — ",
DefaultValue = " — "
},
new AttributeItem() {
Name = "OnCustomFilter",
Description = "自定义集合过滤规则",
Type = "Func<string, Task<IEnumerable<TValue>>>",
ValueList = " — ",
DefaultValue = " — "
},
new AttributeItem() {
Name = "OnGetDisplayText",
Description = "通过模型获得显示文本方法",
Type = "Func<TValue, string>",
ValueList = " — ",
DefaultValue = " — "
},
new AttributeItem() {
Name = "OnSelectedItemChanged",
Description = "选项改变回调方法",
Type = "Func<TValue, Task>",
ValueList = " — ",
DefaultValue = " — "
},
new AttributeItem() {
Name = "Template",
Description = "候选项模板",
Type = "RenderFragment<TValue>",
ValueList = " — ",
DefaultValue = " — "
}
};
// TODO: 移动到数据库中
new AttributeItem() {
Name = "DisplayCount",
Description = "匹配数据时显示的数量",
Type = "int",
ValueList = " — ",
DefaultValue = " — "
},
new AttributeItem() {
Name = "NoDataTip",
Description = "无匹配数据时显示提示信息",
Type = "string",
ValueList = " — ",
DefaultValue = "无匹配数据"
},
new AttributeItem() {
Name = "IgnoreCase",
Description = "匹配时是否忽略大小写",
Type = "bool",
ValueList = "true/false",
DefaultValue = "true"
},
new AttributeItem() {
Name = "IsLikeMatch",
Description = "是否开启模糊查询",
Type = "bool",
ValueList = "true/false",
DefaultValue = "false"
},
new AttributeItem() {
Name = "Items",
Description = "组件数据集合",
Type = "IEnumerable<TValue>",
ValueList = " — ",
DefaultValue = " — "
},
new AttributeItem() {
Name = "OnCustomFilter",
Description = "自定义集合过滤规则",
Type = "Func<string, Task<IEnumerable<TValue>>>",
ValueList = " — ",
DefaultValue = " — "
},
new AttributeItem() {
Name = "OnGetDisplayText",
Description = "通过模型获得显示文本方法",
Type = "Func<TValue, string>",
ValueList = " — ",
DefaultValue = " — "
},
new AttributeItem() {
Name = "OnSelectedItemChanged",
Description = "选项改变回调方法",
Type = "Func<TValue, Task>",
ValueList = " — ",
DefaultValue = " — "
},
new AttributeItem() {
Name = "Template",
Description = "候选项模板",
Type = "RenderFragment<TValue>",
ValueList = " — ",
DefaultValue = " — "
},
new AttributeItem()
{
Name = nameof(AutoFill<string>.SkipEnter),
Description = "是否跳过 Enter 按键处理",
Type = "bool",
ValueList = "true/false",
DefaultValue = "false"
},
new AttributeItem()
{
Name = nameof(AutoFill<string>.SkipEsc),
Description = "是否跳过 Esc 按键处理",
Type = "bool",
ValueList = "true/false",
DefaultValue = "false"
}
};
}