【问题标题】:Bootstrap-Table Get Saved CookiesBootstrap-Table 获取保存的 Cookie
【发布时间】: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


    【解决方案1】:

    你应该像这样使用它: $("#table").bootstrapTable('getCookies')

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-04-29
      • 1970-01-01
      • 2022-01-02
      • 1970-01-01
      • 2019-06-25
      • 2020-09-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多