如何在刷新时更改 bootstrap table 属性

How do I change bootstrap table properties on refresh

我在Github上用的是bootstrap-table文之信就是这个

我想在刷新时将 table 设置从 clickToSelect: true 更改为 clickToSelect: false

这是我的代码:

HTML

<html>
  <button id="refresh"> Refresh
  </button>
  <table id="table">
  </table>
<html>

JAVASCRIPT

$(function () {
    $('#table').bootstrapTable({
                method: 'get',
                url:"http://139.199.18.128/Home/GetJSON2",
                clickToSelect: true,
                columns: [
                            { checkbox: true },
                            { field: "name", title: "lon"},
                            { field: "customID", title: "level"}
                         ]
                });

   $("#refresh").click(function () {

     $("#table").bootstrapTable("refresh",
                {

                });
   });

});

$("#table").bootstrapTable("refresh",
                {  method: 'post',
                   url: "myUrl",
                   clickToSelect: false
                });

希望能得到解决方案。 谢谢。

为什么在刷新按钮处理程序之外使用 refreshOptions 进行调用?像这样尝试:

$(function() {
    $('#table').bootstrapTable({
        method: 'get',
        url: "http://139.199.18.128/Home/GetJSON2",
        clickToSelect: true,
        columns: [{
                checkbox: true
            },
            {
                field: "name",
                title: "lon"
            },
            {
                field: "customID",
                title: "level"
            }
        ]
    });

    $("#refresh").click(function() {

        $("#table").bootstrapTable("refreshOptions", {
            clickToSelect: false,
            // Other options you want to override
        });
    });

});

编辑

如果您只想更改 clickToSelect 字段,请选中:http://jsfiddle.net/edvejew5/

如果您想 disable/enable 复选框,请勾选: http://jsfiddle.net/j9h62fk6/(可能更干净,但这是一个开始)