Bootstrap-Table获取保存的Cookie

问题描述 投票:0回答:1

我正在使用bootstrap-Table来显示表格数据我使用bootstrap-table-cookie.js来启用浏览器中的状态保存

我的要求是我需要将这些保存的cookie(状态)保存到SQL服务器,并且下次登录保存状态的用户应该返回。

我已经按照链接BS-Cookie尝试了getCookies方法,但它总是返回null

我的守则

  <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的结果始终为null。

有人可以举一个很好的例子来获取bootstrap-table保存的cookie值

bootstrap-table
1个回答
0
投票

你应该使用:$(“#table”)。bootstrapTable('getCookies')

© www.soinside.com 2019 - 2024. All rights reserved.