jquery refresh table data

    function RefreshTbody(action, searchVal) {
        $.get('ajax.php', { action: action, value: searchVal }, function (data) {
            var json = jQuery.parseJSON(data);
            $(function () {
                var content = '';
                //content += '<tbody>'; -- **superfluous**
                for (var i = 0; i < json.length; i++) {
                    content += '<tr id="' + json[i].ID + '">';
                    content += '<td><input id="check_' + json[i].ID + '" name="check_' + json[i].ID + '" type="checkbox" value="' + json[i].ID + '" autocomplete=OFF /></td>';
                    content += '<td>' + json[i].ID + '</td>';
                    content += '<td>' + json[i].Name + '</td>';
                    content += '<td>' + json[i].CountryCode + '</td>';
                    content += '<td>' + json[i].District + '</td>';
                    content += '<td>' + json[i].Population + '</td>';
                    content += '<td><a href="#" class="edit">Edit</a> <a href="#" class="delete">Delete</a></td>';
                    content += '</tr>';
                }
                // content += '</tbody>';-- **superfluous**
                //$('table tbody').replaceWith(content);  **incorrect..**
                $('#myTable tbody').html(content);  // **better. give the table a ID, and replace**
            });
        });
    };

在使用BootstrapTable插件时,refresh列命令用于刷新表格中的数据。refresh列的功能是重新加载表格,以便更新表格中的数据,让表格显示最新的内容。 使用refresh列命令,可以通过以下步骤来刷新BootstrapTable中的列: 1. 在HTML文件中,引入BootstrapTablejQuery两个库的相关文件。 2. 在HTML文件中,创建一个表格的容器,用于显示BootstrapTable。 3. 在JavaScript中,使用BootstrapTable的初始化参数配置表格。包括列的设置、数据的来源等。 4. 在HTML文件中,创建一个按钮或其他元素,用于触发刷新列的操作。 5. 在JavaScript中,为按钮或其他触发元素添加点击事件,调用refresh列命令。 6. 在refresh列命令中,使用BootstrapTable的方法refresh来刷新表格。 示例代码如下: ```html <!DOCTYPE html> <html> <head> <title>BootstrapTable Refresh Column</title> <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css"> <script src="http://cdn.bootcss.com/jquery/2.2.2/jquery.min.js"></script> <script src="http://cdn.bootcss.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> <script src="http://cdn.bootcss.com/bootstrap-table/1.11.1/bootstrap-table.min.js"></script> </head> <body> <div class="container"> <table id="myTable"></table> <button id="refreshBtn">刷新列</button> </div> <script type="text/javascript"> $(function() { $('#myTable').bootstrapTable({ columns: [{ field: 'id', title: 'ID' }, { field: 'name', title: '姓名' }, { field: 'age', title: '年龄' }], data: [{ id: 1, name: '张三', age: 20 }, { id: 2, name: '李四', age: 25 }] }); $('#refreshBtn').click(function() { $('#myTable').bootstrapTable('refresh'); }); }); </script> </body> </html> ``` 以上就是关于使用refresh列命令刷新BootstrapTable中列的方法。在表格显示的时候,点击"刷新列"按钮,即可重新加载表格数据,实现列的刷新。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值