/// <summary> /// 点击列进行排序方法 /// </summary> protected async Task OnClickHeader(ITableColumn col) { if (col.Sortable) { if (SortOrder == SortOrder.Unset) { SortOrder = SortOrder.Asc; } else if (SortOrder == SortOrder.Asc) { SortOrder = SortOrder.Desc; } else if (SortOrder == SortOrder.Desc) { SortOrder = SortOrder.Unset; } SortName = col.GetFieldName(); // 通知 Table 组件刷新数据 if (OnSortAsync != null) { await OnSortAsync.Invoke(); } } }
/// <summary> /// 获得 指定单元格数据方法 /// </summary> /// <param name="col"></param> /// <param name="item"></param> /// <returns></returns> protected RenderFragment GetValue(ITableColumn col, TItem item) => async builder => { if (col.Template != null) { builder.AddContent(0, col.Template.Invoke(item)); } else { string content = ""; var val = GetItemValue(col.GetFieldName(), item); if (col.Formatter != null) { // 格式化回调委托 content = await col.Formatter(val); } else if (!string.IsNullOrEmpty(col.FormatString)) { // 格式化字符串 content = val?.Format(col.FormatString) ?? ""; } else if (col.FieldType.IsEnum()) { content = col.FieldType.ToDescriptionString(val?.ToString()); } else { content = val?.ToString() ?? ""; } builder.AddContent(0, content); } };
private RenderFragment GetValue(ITableColumn col) => new RenderFragment(builder => { if (col.Template != null) { if (Item != null) { builder.AddContent(0, col.Template.Invoke(Item)); } } else { builder.AddContent(0, GetItemValue(col.GetFieldName())); } });
/// <summary> /// 点击列进行排序方法 /// </summary> protected Func <Task> OnClickHeader(ITableColumn col) => async() => { if (SortOrder == SortOrder.Unset) { SortOrder = SortOrder.Asc; } else if (SortOrder == SortOrder.Asc) { SortOrder = SortOrder.Desc; } else if (SortOrder == SortOrder.Desc) { SortOrder = SortOrder.Unset; } SortName = col.GetFieldName(); // 通知 Table 组件刷新数据 await IntenralOnSortAsync(SortName, SortOrder); };
private bool GetColumnsListState(ITableColumn col) { return(ColumnVisibles.First(i => i.FieldName == col.GetFieldName()).Visible&& ColumnVisibles.Count(i => i.Visible) == 1); }