x可编辑插件与bootstrap 3和bootstrap-table的兼容性



我使用bootstrap 3和bootstrap-table,我试图使用x-editable插件使单元格可编辑。当我使用"弹出"模式并想编辑单元格时,在单元格旁边会显示另一个空单元格。我不确定这是不是一个bug。

jsfiddle

<table class="table table-striped table-bordered table-hover"  cellspacing="0" id="mainTable" data-click-to-select="true" data-show-toggle="true" data-show-columns="true" data-search="true" data-pagination="true">
<thead>
<tr>
    <th data-field="name" data-halign="center" data-align="left" data-sortable="true">Name</th>
    <th data-field="stargazers_count" data-halign="center" data-align="left" data-sortable="true">Stars</th>
    <th data-field="forks_count" data-halign="center" data-align="left" data-sortable="true">Forks</th>
    <th data-field="description" data-halign="center" data-align="left" data-sortable="true">Description</th>
</tr>
</thead>

JS

var data = [{name: 'ala', stargazers_count: 234, forks_count: 234, description: "asdasdas"},
           {name: 'ala', stargazers_count: 234, forks_count: 234, description: "asdasdas"},
           {name: 'ala', stargazers_count: 234, forks_count: 234, description: "asdasdas"}]
$('table').bootstrapTable({
    data: data
});
$('table tbody tr td').editable();

您必须使用这个bootstrap-table-edit扩展:https://github.com/wenzhixin/bootstrap-table/tree/master/src/extensions/editable

下面是一个工作示例:http://issues.wenzhixin.net.cn/bootstrap-table/

编辑:

查看这个JSFiddle

三件事:

  • 为脚本添加bootstrap-table-editable扩展名
  • 将属性data-editable="true"添加到每一列
  • 删除JavaScript代码:$('table tbody tr td').editable();,因为它不需要

查看此页面的其他扩展:http://bootstrap-table.wenzhixin.net.cn/extensions/

最新更新