欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

BootStrap Table 后臺(tái)數(shù)據(jù)綁定、特殊列處理、排序功能

 更新時(shí)間:2017年05月27日 09:49:45   作者:meetweb  
本節(jié)主要介紹Bootstrap的后臺(tái)數(shù)據(jù)綁定、特殊列處理及列的排序功能,代碼簡(jiǎn)單易懂,非常不錯(cuò),具有參考借鑒價(jià)值,需要的的朋友參考下吧

本節(jié)主要介紹Bootstrap的后臺(tái)數(shù)據(jù)綁定、特殊列處理及列的排序功能

1.數(shù)據(jù)綁定

 一般做程序設(shè)計(jì),很少是使用json文件直接綁定數(shù)據(jù)?;旧衔覀兌际鞘褂镁幊陶Z(yǔ)言進(jìn)行數(shù)據(jù)獲取,并做數(shù)據(jù)綁定。

放置一個(gè)Table控件

<table id="table" ></table>

調(diào)用javascript的代碼

<script >
$('#table').bootstrapTable({
  url: 'tablejson.jsp',  //數(shù)據(jù)綁定,后臺(tái)的數(shù)據(jù)從jsp代碼
  search:true,      
  uniqueId:"Id",
  pageSize:"5",
  pageNumber:"1",
  sidePagination:"client",
  pagination:true,
  height:'400',
  columns: [
  {
    field: 'Id',
    title: '中文'
  }, {
    field: 'Name',
    title: 'Name'
  }
  , {
    field: 'Desc',
    title: 'Desc'
  }
  ],
});

2.特殊列處理

 在實(shí)際應(yīng)用中,我們需要增加我們的特殊列,例如是操作列,看下列的js代碼 增加了一個(gè)特殊列

{
    field: '#',
    title: 'control',formatter:function(value,row,index){
    var del='<a href="Delete!delete.action?Id='+row.Id+'" rel="external nofollow" rel="external nofollow" >刪除</a>';
    var updt='<a href="supdate.jsp?Id='+row.Id+'" rel="external nofollow" rel="external nofollow" >修改</a>';
    var add='<a href="Include.jsp?Id='+row.Id+'" rel="external nofollow" rel="external nofollow" >增加</a>'
    return del+" "+updt+"&nbsp"+add;
    }
  } 

js的代碼修改為

<script >
$('#table').bootstrapTable({
  url: 'tablejson.jsp',  //數(shù)據(jù)綁定,后臺(tái)的數(shù)據(jù)從jsp代碼
  search:true,      
  uniqueId:"Id",
  pageSize:"5",
  pageNumber:"1",
  sidePagination:"client",
  pagination:true,
  height:'400',
  columns: [
   
  {
    field: 'Id',
    title: '中文'
  }, {
    field: 'Name',
    title: 'Name'
  }
  , {
    field: 'Desc',
    title: 'Desc'
  }
,
{
    field: '#',
    title: 'control',formatter:function(value,row,index){
    var del='<a href="Delete!delete.action?Id='+row.Id+'" rel="external nofollow" rel="external nofollow" >刪除</a>';
    var updt='<a href="supdate.jsp?Id='+row.Id+'" rel="external nofollow" rel="external nofollow" >修改</a>';
    var add='<a href="Include.jsp?Id='+row.Id+'" rel="external nofollow" rel="external nofollow" >增加</a>'
    return del+" "+updt+"&nbsp"+add;
    }
  }
], }); 

3.列的排序,排序主要是在列中增加了一個(gè)屬性

{
    field: 'Name',
    title: 'Name',<br><em id="__mceDel">sortable:true</em>
}

以上所述是小編給大家介紹的BootStrap Table 后臺(tái)數(shù)據(jù)綁定、特殊列處理、排序功能,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評(píng)論