bootstrap table操作技巧

相关资料

http://blog.csdn.net/daniel_lixuan/article/details/53197618
http://bootstrap-table.wenzhixin.net.cn/documentation/
https://github.com/wenzhixin/bootstrap-table/

ptions:Object
proto:Object
async:false
buttonsAlign:”right”
cache:false
cardView:false
checkboxHeader:true
classes:”table table-hover”
clickToSelect:false
columns:Array(1)
contentType:”application/json”
data:Array(146)
dataField:”rows”
dataType:”json”
detailFormatter:function (index, row)
detailView:false
editable:Editable
exportDataType:”all”
exportOptions:Object
exportTypes:Array(6)
formatAllRows:function ()
formatColumns:function ()
formatDetailPagination:function (totalRows)
formatLoadingMessage:function ()
formatNoMatches:function ()
formatPaginationSwitch:function ()
formatRecordsPerPage:function (pageNumber)
formatRefresh:function ()
formatSearch:function ()
formatShowingRows:function (pageFrom, pageTo, totalRows)
formatToggle:function ()
icons:Object
iconsPrefix:”glyphicon”
maintainSelected:false
method:”get”
minimumCountColumns:1
onAll:function (name, args)
onCheck:function (row)
onCheckAll:function (rows)
onCheckSome:function (rows)
onClickCell:function (field, value, row, element)onClickRow:function(item,element)
onCollapseRow:function (index, row)
onColumnSwitch:function (field, checked)
onDblClickCell:function (field, value, row, element)onDblClickRow:function(item,element)
onEditableHidden:function (field, row, el,reason)onEditableInit:function()onEditableSave:function(field,row,oldValue,el)
onEditableShown:function (field, row, el,editable)onExpandRow:function(index,row,detail)
onLoadError:function (status)
onLoadSuccess:function (data)
onPageChange:function (number, size)
onPostBody:function ()
onPostHeader:function ()
onPreBody:function (data)
onRefreshOptions:function (options)
onResetView:function ()
onSearch:function (text)
onSort:function (name, order)
onToggle:function (cardView)
onUncheck:function (row)
onUncheckAll:function (rows)
onUncheckSome:function (rows)
oneditablesave:”my2_onEditableSave”
onlyInfoPagination:false
pageList:Array(4)
pageNumber:1
pageSize:50
pagination:true
paginationDetailHAlign:”left”
paginationFirstText:”首页”
paginationHAlign:”right”
paginationLastText:”末页”
paginationNextText:”下一页”
paginationPreText:”上一页”
paginationVAlign:”bottom”
queryParams:function (params)
queryParamsType:”limit”
responseHandler:function (res)
rowAttributes:function (row, index)
rowStyle:function (row, index)
search:true
searchAlign:”right”
searchText:””
searchTimeOut:500
selectItemName:”btSelectItem”
showColumns:true
showExport:true
showFooter:false
showHeader:true
showPaginationSwitch:false
showRefresh:true
showToggle:false
sidePagination:”client”
silentSort:true
singleSelect:false
smartDisplay:true
sortName:”seq”
sortOrder:”asc”
sortable:true
strictSearch:false
striped:false
toggle:”table”
toolbarAlign:”left”
totalPages:3
totalRows:146
trimOnSearch:true
undefinedText:”-“

源码

html代码

id 名称 ip 国家 提供商

js代码:

//生成后台数据请求参数。后台可以用request.getParameter获取
var bh_agt_queryParams=function(params){
    var tmp = bt_bhagent_paras//外面生成的json格式参数
    bt_bhagent_paras={}
    return tmp
}
var bh_agt_bootstrapresp=function(data){
    bt_bhagent_list = data;
    //这里是动态加载数据后的入口函数。
    //在这里可以对data进行二次加工生成retdata。
    //在这里也可以出发其它的关联动作,比如说画echart图。
    return retdata
}
//对单行数据进行格式化,可以返回各种css
var table_rowFormatter = function(row, index){
     if (row.succ == "SUCCESS"){
         return { classes: 'success' };
    }else if (row.succ == "NOTING"){
        return { classes: 'warning' };
    }
     return { classes: 'danger' };
}
//加载Table数据
var bh_table_update = function(refresh,filter){
    if (refresh){
        $('#'+ filter.eTable).bootstrapTable('refresh',{  
            url: filter.tableUrl
        });
    }else{
        $('#'+ filter.eTable).bootstrapTable({  
            url: filter.tableUrl
        });
    }
} 

知识点说明

  1. bootstrapTable(‘refresh’,{ url: filter.tableUrl}); 的方式在第一次加载数据时会失败。第一次加载数据不能带refresh动作。
  2. 在非第一次加载数据时,必须执行refresh动作,否则数据不会更新到表中。
  3. 如果向直接加载已有数据,则需要使用load动作。如:bootstrapTable(“load”,data);
  4. .bootstrapTable(‘mergeCells’, {index: 0,field: ‘name’,rowspan: 3}); 可以实现行或列的合并
  5. 在refresh等动作中,设置silent: true参数,则不会提示 wait loading。
  6. table id=”baji-table” style=”font-size:10px;” 设置本表字体大小

你可能感兴趣的:(Web前端)