【发布时间】:2018-05-20 08:22:06
【问题描述】:
我正在使用 bootstrap-Table 来显示表格数据 我已经使用 bootstrap-table-cookie.js 在浏览器中启用状态保存
我的要求是我需要将这些保存的 cookie(状态)发送到 SQL 服务器,并且下次用户登录保存状态时应该返回。
我已经按照链接BS-Cookie尝试了getCookies方法,但它总是返回为空
我的代码
<script src="~/assets/bootstrap-table/src/bootstrap-table.js"></script>
<script src="~/assets/bootstrap-table/src/extensions/export/bootstrap-table-export.js"></script>
<script src="~/assets/bootstrap-cookie/bootstrap-table-cookie.js"></script>
<div>
<button id="btnSaveState"> save </button>
</div>
<table id="tblff">
<thead>
<tr>
<th data-field="RID" rowspan="2" class="hdr"
data-cell-style="OperateFormatter">REQID</th>
<th data-field="DTP" rowspan="2"> DT OPENED</th>
<th data-field="SUM" rowspan="2"> SUMM</th>
</tr>
</thead>
</table>
<script type="text/javascript">
$(function () {
$.ajax({
url: initalURL
, type: 'GET'
, contentType: "application/json; charset=utf-8"
, dataType: "json"
, success: function (response) {
$('#CRFTable').bootstrapTable({
data: response.rows
, cookie: true
, cookieIdTable: userID
, showRefresh: true
, showToggle: true
, showColumns: true
, showExport: true
, exportTypes: "['excel']"
, pagination: true
, pageList: "[10, 25, 50, 100, ALL]"
, idField: "RID"
, toolbar: $("#custToolbar")
});
}
, failure: function (response) {
alert(response.responseText);
}
, error: function (response) {
alert(response.responseText);
}
});
$("#btnSaveState").on('click', function () {
try {
var cookieDetails = $('#tblff').bootstrapTable().getCookie();
alert(cookieDetails);
} catch (e) {
}
})
});
</script>
但是 getCookies 的结果总是空的。
有人可以举一个很好的例子来获取 bootstrap-table 保存的 cookie 值
【问题讨论】:
标签: bootstrap-table