bootstrap table 怎么绑定数据


本文摘自PHP中文网,作者(*-*)浩,侵删。

支持三种方式bootstrap table绑定数据:1.html格式数据(即静态数据);2.JavaScript传递数据;3.数据属性变量动态获取。

静态表格:data-toggle="table"(推荐学习:Bootstrap视频教程)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

<table data-toggle="table">

  <thead>

    <tr>

      <th>Item ID</th>

      <th>Item Name</th>

      <th>Item Price</th>

    </tr>

  </thead>

  <tbody>

    <tr>

      <td>1</td>

      <td>Item 1</td>

      <td>$1</td>

    </tr>

    <tr>

      <td>2</td>

      <td>Item 2</td>

      <td>$2</td>

    </tr>

  </tbody>

</table>

JavaScript方式

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

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

<!--定义一个表格,无需设置表头,统一在JS中初始化,灵活度较高(梁新建议)-->

<script>

$('#table').bootstrapTable({

  url: 'data1.json',

  pagination: true,

  search: true

  columns: [{

    field: 'id',

    title: 'Item ID'

  }, {

    field: 'name',

    title: 'Item Name'

  }, {

    field: 'price',

    title: 'Item Price'

  }, ]

})

</script>

数据属性变量动态获取

1

2

3

4

5

6

7

8

9

10

11

12

13

<table

  data-toggle="table"

  data-url="data1.json"

  data-pagination="true"

  data-search="true">

  <thead>

    <tr>

      <th data-sortable="true" data-field="id">Item ID</th>

      <th data-field="name">Item Name</th>

      <th data-field="price">Item Price</th>

    </tr>

  </thead>

</table>

更多Bootstrap相关技术文章,请访问Bootstrap教程栏目进行学习!

以上就是bootstrap table 怎么绑定数据的详细内容,更多文章请关注木庄网络博客

相关阅读 >>

bootstrap什么时候开源的

如何解决bootstrap 图标不显示的问题

bootstrap框架的好处

bootstrap4如何设置模态框

bootstrap怎么适配

bootstrap是什么意思啊

bootstrap如何设置响应式表格

bootstrap怎么改样式

bootstrap和vue的区别

dialog是bootstrap的么

更多相关阅读请进入《bootstrap》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...