我试图将表中的字段设置为可编辑的引导表,但我无法这样做:http://issues.wenzhixin.net.cn/bootstrap-table/#extensions/editable.html
我正在加载JSON数据,对列进行排序,但不能做到这一点:表中的每个字段都是可编辑的。
<head>
<title>custom-sort</title>
<meta charset="utf-8">
<link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="assets/bootstrap/css/bootstrap-table.min.css">
<link rel="stylesheet" href="assets/examples.css">
<script src="assets/jquery.min.js"></script>
<script src="assets/jquery.dataTables.min.js"></script>
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
<script src="assets/bootstrap-table/src/bootstrap-table-custom.min.js"></script>
<script src="assets/bootstrap-table/src/bootstrap-table-editable.js"></script>
<script src="ga.js"></script>
</head>
<body>
<div class="container">
<h1>Custom Sort</h1>
<p>Use <code>sorter</code> column option to define the custom sort of bootstrap table.</p>
<table id="table" class="table table-bordered table-striped" data-editable="true" data-toggle="table" data-url="json/data1.json" data-pagination="true"></table>
</div>$('#table').bootstrapTable({
url: 'json/data1.json',
columns: [{
field: 'id',
title: 'Item ID',
sortable: 'true',
editable: 'true'
}, {
field: 'name',
title: 'Item Name',
sortable: 'true',
editable: 'true'
}, {
field: 'price',
title: 'Item Price',
sortable: 'true',
editable: 'true'
}, ]
});
var $table = $('#table');
$(function () {
$table.on('click-row.bs.table', function (e, row, $element) {
$('.success').removeClass('success');
$($element).addClass('success');
});
});JSON
[{
"id": 0,
"name": "Item 0",
"price": "$0"
},{
"id": 1,
"name": "Item 1",
"price": "$1"
},{
"id": 2,
"name": "Item 2",
"price": "$2"
}]你能帮我做所有可编辑的表域吗?
发布于 2016-11-07 20:42:48
下面的示例显示具有可编辑字段“name”的表初始化:
function initTable() {
$table.bootstrapTable({
height: getHeight(),
columns: [
[
{
field: 'state',
checkbox: true,
rowspan: 2,
align: 'center',
valign: 'middle'
}, {
title: 'Item ID',
field: 'id',
rowspan: 2,
align: 'center',
valign: 'middle',
sortable: true,
footerFormatter: totalTextFormatter
}, {
title: 'Item Detail',
colspan: 3,
align: 'center'
}
],
[
{
field: 'name',
title: 'Item Name',
sortable: true,
editable: true,
footerFormatter: totalNameFormatter,
align: 'center'
}, {
field: 'price',
title: 'Item Price',
sortable: true,
align: 'center',
editable: {
type: 'text',
title: 'Item Price',
validate: function (value) {
value = $.trim(value);
if (!value) {
return 'This field is required';
}
if (!/^\$/.test(value)) {
return 'This field needs to start width $.'
}
var data = $table.bootstrapTable('getData'),
index = $(this).parents('tr').data('index');
console.log(data[index]);
return '';
}
},
footerFormatter: totalPriceFormatter
}, {
field: 'operate',
title: 'Item Operate',
align: 'center',
events: operateEvents,
formatter: operateFormatter
}
]
]
});来源:http://issues.wenzhixin.net.cn/bootstrap-table/#options/detail-view.html
发布于 2016-01-15 12:32:30
可编辑表是一个表操作插件,它将一个标准的Html表转换为一个响应响应的就地可编辑电子表格,并基于jQuery和引导2/3进行输入验证。
http://www.jqueryscript.net/table/Stylish-Editable-Table-Plugin-with-jQuery-Bootstrap-2-3-Editable-Table.html
发布于 2016-01-21 16:50:27
似乎您缺少了一些css (bootstrap-edable.css)文件和js (bootstrap-udable.js)文件,还包括了一些其他js (jquery.dataTables.min.js)。
试着再次查看消息来源。
https://stackoverflow.com/questions/34810077
复制相似问题