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 ...
随机推荐
- web自动化测试用例编写的规范
1.一个脚本是一个完整的场景,从用户登陆操作到用户退出系统关闭浏览器. 2.一个脚本脚本只验证一个功能点,不要试图用户登陆系统后把所有的功能都进行验证再退出系统 3.尽量只做功能中正向逻辑的验证,不要 ...
- mac终端所有命令不能用
最近一次在用终端敲命令的时候发现命令总是不执行(只有cd命令可以正常执行),返回命令未识别的错误-bash: source: command not found 相信很多朋友也会遇到类似的问题. 解决 ...
- 使用 Spring 访问 Hibernate 的方法有哪些?
我们可以通过两种方式使用 Spring 访问 Hibernate: 1. 使用 Hibernate 模板和回调进行控制反转 2. 扩展 HibernateDAOSupport 并应用 AOP 拦截器节 ...
- django 三件套(render,redirect,HttpResponse)
Django基础必备三件套**: HttpResponse 内部传入一个字符串参数,返回给浏览器. from django.shortcuts import HttpResponse def inde ...
- Python中module文件夹里__init__.py的功能
怎么引用模块 环境:win7 + python3.5.2文档结构: -project -data -src -filterCorpus.py -translateMonolingual.py 问题 ...
- 转Gerber和拼版
1 Gerber 这个网上有现成的教程:(不要写网上能找到的资料-敏捷开发) AD 导出Gerber :https://jingyan.baidu.com/article/3c48dd3494181c ...
- 【静态页面架构】CSS之定位
CSS架构 1.浮动: 是以float属性设置容器指定的位置 <style> div { width: 200px; height: 200px; } #qq { background-c ...
- 微信小程序从注册到上线系列
为了帮助同学们了解注册及上线的整个流程,所以在开发之外,我专门制作了这个从注册到上线流程:本专辑不涉及任何跟开发有关的事情,开发专辑请看:实战开发宝典 以下为具体内容: 从注册到上线系列<一&g ...
- EMS批量为用户分配邮箱
组织单位"Office"下有10个域用户,可以通过PowerShell命令一次为该组织单位中的没有分配邮箱的域用户分配邮箱. 以Exchange管理员身份打开EMS控制台.在Pow ...
- BootstrapBlazor实战 Chart 图表使用(1)
BootstrapBlazor组件 Chart 图表介绍 通过给定数据,绘画各种图表的组件 本文主要介绍三种图表使用:折线图,柱状图,饼图 1.新建工程 新建工程b06chart,使用 nuget.o ...