简体   繁体   English

如何在刷新时更改引导程序表属性

[英]How do I change bootstrap table properties on refresh

I am using bootstrap-table by wenzhixin on Github it is this one 我在GitHub上使用wenzhixin的bootstrap-table就是这个

I want to change table settings from clickToSelect: true to clickToSelect: false on refresh 我想将表格设置从clickToSelect: true更改为clickToSelect: false刷新时为clickToSelect: false

Here is my Code : 这是我的代码:

HTML 的HTML

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

JAVASCRIPT 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
                });

I hope I can get a solution. 希望我能找到解决方案。 Thanks. 谢谢。

Why is the call with refreshOptions outside of refresh button handler ? 为什么用refreshOptions进行的调用在刷新按钮处理程序之外? Try like this: 尝试这样:

$(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
        });
    });

});

EDIT 编辑

If you want only to change clickToSelect field, check this: http://jsfiddle.net/edvejew5/ 如果只想更改clickToSelect字段,请检查以下内容: http : //jsfiddle.net/edvejew5/

If you want to disable/enable the checkboxes, check this: http://jsfiddle.net/j9h62fk6/ ( could be much cleaner, but it's a start) 如果要禁用/启用复选框,请检查以下内容: http : //jsfiddle.net/j9h62fk6/ (可能更干净,但这只是一个开始)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM