【问题标题】:How do I change bootstrap table properties on refresh如何在刷新时更改引导表属性
【发布时间】:2018-07-04 10:52:33
【问题描述】:

我在 Github 上使用 wenzhixin 的 bootstrap-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
                });

我希望我能得到一个解决方案。 谢谢。

【问题讨论】:

标签: javascript asp.net asp.net-mvc twitter-bootstrap bootstrap-table


【解决方案1】:

为什么在刷新按钮处理程序之外使用 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/

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

【讨论】:

  • 我试过了 表格可以刷新,但点击时仍然无法选择行。 @BorisS
  • @Elijah 请检查编辑
猜你喜欢
  • 1970-01-01
  • 2010-11-10
  • 1970-01-01
  • 1970-01-01
  • 2021-02-22
  • 2015-11-14
  • 2018-03-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多