Bootstrap Blazor Table 组件(四)自定义列生成
原文链接:https://www.cnblogs.com/ysmc/p/16223154.html
Bootstrap Blazor 官方链接:https://www.blazor.zone/tables
上一篇文章说到 Table 组件的智能生成,有了自动生成,肯定会有自定义的。
一、指定生成列
除了可以在 AutoGenerateColumnAttribute 特性中指定每一列的行为外,我们可以手动在 Table 的 TableColumns 标签中自定义要展现的列与列具有的行为,在此之前,我们要先将 AutoGenerateColumns 属性设置成 false(该属性默认为 false):
<Table TItem="Foo" IsPagination="true" PageItemsSource="PageItemsSource" ShowFooter="true"
IsStriped="true" IsBordered="true" ShowSkeleton="true" IsMultipleSelect="true"
ShowToolbar="true" ShowSearch="true" ShowExtendButtons="true" OnQueryAsync="@OnQueryAsync"
AutoGenerateColumns="false" EditMode="EditMode.Popup">
<TableColumns>
<TableColumn @bind-Field="@context.Name"></TableColumn>
<TableColumn @bind-Field="@context.DateTime"></TableColumn>
<TableColumn @bind-Field="@context.Address"></TableColumn>
<TableColumn @bind-Field="@context.Count"></TableColumn>
</TableColumns>
</Table>

二、定义列功能
我们还可以在 TableColumn 中指定每一列具有的功能,如过滤、排序、是否可编辑等等;在此,我们将日期(DateTime) 与 数量(Count) 两列分别赋予排序与过滤功能
<Table TItem="Foo" IsPagination="true" PageItemsSource="PageItemsSource" ShowFooter="true"
IsStriped="true" IsBordered="true" ShowSkeleton="true" IsMultipleSelect="true"
ShowToolbar="true" ShowSearch="true" ShowExtendButtons="true" OnQueryAsync="@OnQueryAsync"
AutoGenerateColumns="false" EditMode="EditMode.Popup">
<TableColumns>
<TableColumn @bind-Field="@context.Name"></TableColumn>
<TableColumn @bind-Field="@context.DateTime" Sortable="true" Filterable="true"></TableColumn>
<TableColumn @bind-Field="@context.Address"></TableColumn>
<TableColumn @bind-Field="@context.Count" Sortable="true" Filterable="true"></TableColumn>
</TableColumns>
</Table>

可以看到,过滤功能还会根据你的属性类型,自动生成日期选择框,免除你还要手动输入烦恼,同时,新增 与 编辑 按钮也会根据你设置的列自动生成相应的表单:

三、自定义单元格
肯定有小伙伴问了,那我想自定义每一个单元格可以吗?那必须是可以的,使用 TableColumn 中的 Template 可以实现你任何想要实现的效果,下面我来演示一下,例如当数量小于 30 时,将数量显示成红色:
<Table TItem="Foo" IsPagination="true" PageItemsSource="PageItemsSource" ShowFooter="true"
IsStriped="true" IsBordered="true" ShowSkeleton="true" IsMultipleSelect="true"
ShowToolbar="true" ShowSearch="true" ShowExtendButtons="true" OnQueryAsync="@OnQueryAsync"
AutoGenerateColumns="false" EditMode="EditMode.Popup">
<TableColumns>
<TableColumn @bind-Field="@context.Name"></TableColumn>
<TableColumn @bind-Field="@context.DateTime" Sortable="true" Filterable="true"></TableColumn>
<TableColumn @bind-Field="@context.Address"></TableColumn>
<TableColumn @bind-Field="@context.Count" Sortable="true" Filterable="true">
<Template Context="row">
@if (row.Value < 30)
{
<span>
<font color="red">
@row.Value
</font>
</span>
}
else
{
<span>
<font>
@row.Value
</font>
</span>
}
</Template>
</TableColumn>
</TableColumns>
</Table>

写在最后
Bootstrap Blazor 官网地址:https://www.blazor.zone
希望大佬们看到这篇文章,能给项目点个star支持下,感谢各位!
star流程:
1、访问点击项目链接:BootstrapBlazor
2、点击star,如下图,即可完成star,关注项目不迷路:

另外还有两个GVP项目,大佬们方便的话也点下star呗,非常感谢:
BootstrapAdmin 项目地址:
https://gitee.com/LongbowEnterprise/BootstrapAdmin
SliderCaptcha 项目地址:
https://gitee.com/LongbowEnterprise/SliderCaptcha
交流群(QQ)欢迎加群讨论
BA & Blazor ①(795206915) BA & Blazor ②(675147445)


Bootstrap Blazor Table 组件(四)自定义列生成的更多相关文章
- Bootstrap Blazor Table 组件(二)
原文链接:https://www.cnblogs.com/ysmc/p/16128206.html 很多小伙伴在使用 Bootstrap Blazor Table组件的时候,都会有这样的一个需求: 我 ...
- Bootstrap Blazor Table 组件(三)智能生成
原文链接:https://www.cnblogs.com/ysmc/p/16201153.html Bootstrap Blazor 官网地址:https://www.blazor.zone 有了解过 ...
- 在 Element-UI 的 Table 组件上添加列拖拽效果
Element-UI 的 Table组件很强大,但是我们的需求更强大... 简单粗暴的来一发效果图: 一.数据驱动 传统的拖动效果,都是基于通过 mousedown.mousemove.mouseup ...
- 利用bootstrap的modal组件自定义alert,confirm和modal对话框
由于浏览器提供的alert和confirm框体验不好,而且浏览器没有提供一个标准的以对话框的形式显示自定义HTML的弹框函数,所以很多项目都会自定义对话框组件.本篇文章介绍自己在项目中基于bootst ...
- Bootstrap Blazor 更新版本 5.6.0
Bootstrap Blazor 是一款基于 Bootstrap 的 企业级 Blazor UI 组件库,目前内置近 90 个组件,欢迎大家尝试使用.本次更新全面升级支持 Bootstrap V5.6 ...
- Bootstrap Blazor 组件介绍 Table (一)自动生成列功能介绍
Bootstrap Blazor 是一套企业级 UI 组件库,适配移动端支持各种主流浏览器,已经在多个交付项目中使用.通过本套组件可以大大缩短开发周期,节约开发成本.目前已经开发.封装了 70 多个组 ...
- Bootstrap Blazor 组件介绍 Table (二)自定义模板列功能介绍
Bootstrap Blazor 是一套企业级 UI 组件库,适配移动端支持各种主流浏览器,已经在多个交付项目中使用.通过本套组件可以大大缩短开发周期,节约开发成本.目前已经开发.封装了 70 多个组 ...
- Bootstrap Blazor 组件介绍 Table (三)列数据格式功能介绍
Bootstrap Blazor 是一套企业级 UI 组件库,适配移动端支持各种主流浏览器,已经在多个交付项目中使用.通过本套组件可以大大缩短开发周期,节约开发成本.目前已经开发.封装了 70 多个组 ...
- 饿了么组件--table组件自定义渲染列,同时伴有v-for和v-if情况
如题,有一个需求,列数量不固定,在一定条件下,可能会(fixedColumn, A2, A3, A4)或(fixedColumn, B2, B3)情况,其中A2, A3, A4会同时出现,B2, B3 ...
随机推荐
- Spring框架中有哪些不同类型的事件?
Spring 提供了以下5种标准的事件: (1)上下文更新事件(ContextRefreshedEvent):在调用ConfigurableApplicationContext 接口中的refre ...
- 如何给Spring 容器提供配置元数据?
这里有三种重要的方法给Spring 容器提供配置元数据. XML配置文件. 基于注解的配置. 基于java的配置.
- java的jsr303校验
因为是菜鸡,所以就还没有具体了解jsr303具体是什么 JSR是Java Specification Requests的缩写,意思是Java 规范提案.是指向JCP(Java Community Pr ...
- 什么是 Callable 和 Future?
Callable 接口类似于 Runnable,从名字就可以看出来了,但是 Runnable 不会返 回结果,并且无法抛出返回结果的异常,而 Callable 功能更强大一些,被线程执 行后,可以返回 ...
- Flask-Migrate使用教程
功能:flask-migrate是flask的一个扩展模块,主要是扩展数据库表结构的. 项目准备:一个干净的Flask项目,下载连接地址: https://pan.baidu.com/s/1WqdIN ...
- Vue报错之" [Vue warn]: Unknown custom element: <wzwzihello> - did you register the component correctly? For recursive components, make sure to provide the "name" option."
一.报错截图 [Vue warn]: Unknown custom element: <wzwzihello> - did you register the component corre ...
- c语言思维导图
- Python这些位运算的妙用,绝对让你大开眼界
位运算的性能大家想必是清楚的,效率绝对高.相信爱好源码的同学,在学习阅读源码的过程中会发现不少源码使用了位运算.但是为啥在实际编程过程中应用少呢?想必最大的原因,是较为难懂.不过,在面试的过程中,在手 ...
- jquery+html5实现单张图片上传预览
js: if (window.File && window.FileReader && window.FileList && window.Blob){ ...
- React+dva+webpack+antd-mobile 实战分享(二)
第一篇 https://segmentfault.com/a/11... 在上一篇文章中教给大家了怎么搭建项目的架子:那么今天我们就来说一下项目里的导航和列表的实现 导航 废话不说啦 下面直接给大家讲 ...