Bootstrap Table使用整理(二)
相關(guān)閱讀:
Bootstrap Table使用整理(一) http://www.dbjr.com.cn/article/115789.htm
Bootstrap Table使用整理(三) http://www.dbjr.com.cn/article/115795.htm
Bootstrap Table使用整理(四)之工具欄 http://www.dbjr.com.cn/article/115798.htm
Bootstrap Table使用整理(五)之分頁組合查詢 http://www.dbjr.com.cn/article/115785.htm
一、行樣式修改
<table id="table1" data-row-style="rowStyle"></table> /* * data-row-style 擴(kuò)展方法處理 行樣式 */ $('#table1').bootstrapTable({ columns: [ { field: 'sno', title: '學(xué)生編號' }, { field: 'sname', title: '學(xué)生姓名' }, { field: 'ssex', title: '性別' }, { field: 'sbirthday', title: '生日' }, { field: 'class', title: '課程編號' }, ], url:'@Url.Action("GetStudent","DataOne")' }); /** * * @@param row 當(dāng)前行數(shù)據(jù)對象 * @@param index 當(dāng)前行索引 */ function rowStyle(row, index) { var classes = ['active', 'success', 'info', 'warning', 'danger']; if (row.sno.indexOf('2') != -1) { return { classes:['success'] } } return {}; }
二、單元格樣式定義,對齊方式定義
/* * data-cell-style 擴(kuò)展方法處理 單元格樣式 * data-align 設(shè)置當(dāng)前列的對齊方式,包括表頭 * data-halign 設(shè)置表格標(biāo)題的對齊方式,優(yōu)先級大于 align */ $('#table1').bootstrapTable({ columns: [ { field: 'sno', title: '學(xué)生編號', align: 'center', halign:'right', cellStyle: function (value, row, index) { //當(dāng)前列,奇數(shù)單元格顯示綠色 if (index%2==0) return { classes: 'success' }; return {}; } }, { field: 'sname', title: '學(xué)生姓名' }, { field: 'ssex', title: '性別' }, { field: 'sbirthday', title: '生日' }, { field: 'class', title: '課程編號' }, ], url:'@Url.Action("GetStudent","DataOne")' });
三、排序列定義
/* * data-sortable 設(shè)置當(dāng)前列是否可排序,默認(rèn)當(dāng)前顯示內(nèi)容排序 * data-sort-name 設(shè)置默認(rèn)排序列名 * data-sort-order 設(shè)置默認(rèn)排序方式 asc/desc * data-sorter 可以自定義擴(kuò)展排序方法 */ $('#table1').bootstrapTable({ columns: [ { field: 'sno', title: '學(xué)生編號', sortable: true }, { field: 'sname', title: '學(xué)生姓名', 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使用整理(二),希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時(shí)回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
相關(guān)文章
JavaScript實(shí)現(xiàn)移動小精靈的案例代碼
這篇文章主要介紹了JavaScript實(shí)現(xiàn)移動小精靈的案例代碼,本文分步驟給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-12-12window.onbeforeunload方法在IE下無法正常工作的解決辦法
下面的代碼可以做到不管用戶是點(diǎn)擊了關(guān)閉,或者是在任務(wù)欄關(guān)閉、點(diǎn)擊后退、刷新、按F5鍵,都可以檢測到用戶即將離開的消息。2010-01-01一段多瀏覽器的"復(fù)制到剪貼板"javascript代碼
一段多瀏覽器的"復(fù)制到剪貼板"javascript代碼...2007-03-03某頁碼顯示的helper 少量調(diào)整,另附j(luò)s版
某頁碼顯示的helper 已經(jīng)少量調(diào)整,另附j(luò)s版,需要的朋友可以參考下。2010-09-09