编辑 table bootstrap-table 中的字段
Edit fields in a table bootstrap-table
我正在尝试将 table 中的字段设为 Bootstrap-Table,即 editable,就像这个例子一样,但我做不到: http://issues.wenzhixin.net.cn/bootstrap-table/#extensions/editable.html
我正在加载 JSON 数据,对列进行排序,但我无法做到 table 中的每个字段都是 editable。
<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": "[=15=]"
},{
"id": 1,
"name": "Item 1",
"price": ""
},{
"id": 2,
"name": "Item 2",
"price": ""
}]
你能帮我完成所有 table 字段 editable 吗?
Editable Table 是一个 table 操作插件,可将标准 Html table 转换为响应式 in-place editable 具有基于 jQuery 和 bootstrap 2/3 的输入验证的电子表格。试试这个 link
似乎您缺少一些 css (bootstrap-editable.css) 文件和 js (bootstrap-editable.js) 文件,您还包含了一些其他 js (jquery.dataTables.min.js).
再次尝试查看来源。
下面的示例显示了一个 table 初始化,字段 'name' 是 editable:
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
我昨天刚刚解决了 ajax 这方面的问题。我将包括所需的库文件和启动 ajax 所需的部分代码(假设您将这样做,因为您正在加载 json)。
<link rel="stylesheet" href="/Includes/jquery/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="/Includes/jquery/bootstrapTable/bootstrap-table.min.css">
<link rel="stylesheet" type="text/css" href="/Includes/jquery/bootstrap3-editable/css/bootstrap-editable.css">
<script src="/Includes/jquery/jquery-3.1.1.min.js"></script>
<script src="/Includes/jquery/bootstrap/js/bootstrap.min.js"></script>
<script src="/Includes/jquery/bootstrapTable/bootstrap-table.min.js"></script>
<script src="../../Includes/jquery/bootstrap3-editable/js/bootstrap-editable.min.js"></script>
<script src="/Includes/jquery/bootstrapTable/bootstrap-table-editable.min.js"></script>
idField: 'id',
columns: [
{field: 'id', title: 'ID', visible: false},
{
field: 'deadline',
title: 'Scheduling<br>Deadline',
editable: {
type: 'text',
url: './edit/edit_well_list.php'
}
},
{
field: 'visit_date',
title: 'Visit<br>Date',
editable: {
type: 'text',
url: './edit/edit_well_list.php'
}
},
]
我正在尝试将 table 中的字段设为 Bootstrap-Table,即 editable,就像这个例子一样,但我做不到: http://issues.wenzhixin.net.cn/bootstrap-table/#extensions/editable.html
我正在加载 JSON 数据,对列进行排序,但我无法做到 table 中的每个字段都是 editable。
<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": "[=15=]"
},{
"id": 1,
"name": "Item 1",
"price": ""
},{
"id": 2,
"name": "Item 2",
"price": ""
}]
你能帮我完成所有 table 字段 editable 吗?
Editable Table 是一个 table 操作插件,可将标准 Html table 转换为响应式 in-place editable 具有基于 jQuery 和 bootstrap 2/3 的输入验证的电子表格。试试这个 link
似乎您缺少一些 css (bootstrap-editable.css) 文件和 js (bootstrap-editable.js) 文件,您还包含了一些其他 js (jquery.dataTables.min.js).
再次尝试查看来源。
下面的示例显示了一个 table 初始化,字段 'name' 是 editable:
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
我昨天刚刚解决了 ajax 这方面的问题。我将包括所需的库文件和启动 ajax 所需的部分代码(假设您将这样做,因为您正在加载 json)。
<link rel="stylesheet" href="/Includes/jquery/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="/Includes/jquery/bootstrapTable/bootstrap-table.min.css">
<link rel="stylesheet" type="text/css" href="/Includes/jquery/bootstrap3-editable/css/bootstrap-editable.css">
<script src="/Includes/jquery/jquery-3.1.1.min.js"></script>
<script src="/Includes/jquery/bootstrap/js/bootstrap.min.js"></script>
<script src="/Includes/jquery/bootstrapTable/bootstrap-table.min.js"></script>
<script src="../../Includes/jquery/bootstrap3-editable/js/bootstrap-editable.min.js"></script>
<script src="/Includes/jquery/bootstrapTable/bootstrap-table-editable.min.js"></script>
idField: 'id',
columns: [
{field: 'id', title: 'ID', visible: false},
{
field: 'deadline',
title: 'Scheduling<br>Deadline',
editable: {
type: 'text',
url: './edit/edit_well_list.php'
}
},
{
field: 'visit_date',
title: 'Visit<br>Date',
editable: {
type: 'text',
url: './edit/edit_well_list.php'
}
},
]