Skip to content

Commit 9e2c6b8

Browse files
committed
doc: 更新示例
1 parent 8c4ac2e commit 9e2c6b8

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/BootstrapBlazor.Server/Components/Samples/Table/TablesColumn.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@
165165
<TableColumn @bind-Field="@context.DateTime" Width="120" FormatString="yyyy-MM-dd" />
166166
<TableColumn @bind-Field="@context.Name" Width="100" />
167167
<TableColumn @bind-Field="@context.Address" />
168-
<TableColumn @bind-Field="@context.Count" FormatString="0.00" />
168+
<TableColumn @bind-Field="@context.Count" Formatter="@IntFormatter" />
169169
</TableColumns>
170170
</Table>
171171
</DemoBlock>

src/BootstrapBlazor.Server/Components/Samples/Table/TablesColumn.razor.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,22 @@ protected override void OnInitialized()
3636

3737
private static bool ShowCheckbox(Foo foo) => foo.Complete;
3838

39+
/// <summary>
40+
/// IntFormatter
41+
/// </summary>
42+
/// <param name="d"></param>
43+
/// <returns></returns>
44+
private static Task<string> IntFormatter(object? d)
45+
{
46+
var ret = "";
47+
if (d is TableColumnContext<Foo, object?> data && data.Value != null)
48+
{
49+
var val = (int)data.Value;
50+
ret = $"Sales: {val:0.00}";
51+
}
52+
return Task.FromResult(ret);
53+
}
54+
3955
private Task<QueryData<Foo>> OnQueryAsync(QueryPageOptions options)
4056
{
4157
IEnumerable<Foo> items = Items;

0 commit comments

Comments
 (0)