Bootstrap Table使用整理(二)
一、行样式修改
- <table id="table1"
- data-row-style="rowStyle"></table>
- /*
- * data-row-style 扩展方法处理 行样式
- */
- $('#table1').bootstrapTable({
- columns: [
- { field: 'sno', title: '学生编号' },
- { field: 'sname', title: '学生姓名' },
- { field: 'ssex', title: '性别' },
- { field: 'sbirthday', title: '生日' },
- { field: 'class', title: '课程编号' },
- ],
- url:'@Url.Action("GetStudent","DataOne")'
- });
- /**
- *
- * @@param row 当前行数据对象
- * @@param index 当前行索引
- */
- function rowStyle(row, index) {
- var classes = ['active', 'success', 'info', 'warning', 'danger'];
- if (row.sno.indexOf('2') != -1) {
- return {
- classes:['success']
- }
- }
- return {};
- }
- /*
- * data-cell-style 扩展方法处理 单元格样式
- * data-align 设置当前列的对齐方式,包括表头
- * data-halign 设置表格标题的对齐方式,优先级大于 align
- */
- $('#table1').bootstrapTable({
- columns: [
- {
- field: 'sno', title: '学生编号',
- align: 'center',
- halign:'right',
- cellStyle: function (value, row, index) {
- //当前列,奇数单元格显示绿色
- if (index%2==0)
- return {
- classes: 'success'
- };
- return {};
- }
- },
- { field: 'sname', title: '学生姓名' },
- { field: 'ssex', title: '性别' },
- { field: 'sbirthday', title: '生日' },
- { field: 'class', title: '课程编号' },
- ],
- url:'@Url.Action("GetStudent","DataOne")'
- });
三、排序列定义
- /*
- * data-sortable 设置当前列是否可排序,默认当前显示内容排序
- * data-sort-name 设置默认排序列名
- * data-sort-order 设置默认排序方式 asc/desc
- * data-sorter 可以自定义扩展排序方法
- */
- $('#table1').bootstrapTable({
- columns: [
- { field: 'sno', title: '学生编号', sortable: true },
- { field: 'sname', title: '学生姓名', sortable: true},
- { field: 'ssex', title: '性别', sortable: true },
- { field: 'sbirthday', title: '生日', sortable: true},
- { field: 'class', title: '课程编号', sortable: true},
- ],
- url:'@Url.Action("GetStudent","DataOne")'
- });
- <table id="table1"
- data-classes="table table-hover table-condensed"
- data-sort-name="sno"
- data-sort-order="desc"></table>
相关推荐
- Bootstrap-table的使用及如何给单元格添加功能按钮和事件等操作!
- iOS:二叉树多级表格的使用,使用三方库TreeTableView-master实现对json解析数据的递归遍历整理成树状结构...
- BootStrap Table使用--删除指定行
- Bootstrap Table使用整理(三)
- Bootstrap Table使用整理(一)
- bootstrap-table使用总结
- Bootstrap Table使用整理(二)
- bootstrap table 使用详细讲解
- 20190328学习笔记 - bootstrap-table插件中的bootstrapTable方法的使用
- Bootstrap-table使用详解
- MacOS升级Catalina后32位锐捷客户端排坑历程
- input输入子系统框架分析