BootStrap table dynamically adds, deletes and modifies the data in the table

API:http://bootstrap-table.wenzhixin.net.cn/zh-cn/documentation/

Simple to use:

1. Add data at the end of the current table

 
  
var _data = {
	"name" : name,
 
  
        ...//add dates
"desc" : desc    }
$("#table_Id").bootstrapTable('append', _data); //_ data----->Added data

2. Add new data in the first row of the current table

 
  
var _data = {
	"name" : name,
        ...//some datas
	"desc" : desc
    }
$("#table_Id").bootstrapTable('prepend', _data); //_ data -----> new data

3. Delete rows according to id

var ids = []; // Define an array 
ids.push(id); // Save the id to be deleted in the array 
$("#table_Id").bootstrapTable('remove', {field: 'id', values: ids}); // field: Determine the row to be deleted according to the value of the field values: The value corresponding to the deleted row

4. Delete all data

$("#table_Id").bootstrapTable('removeAll');

5. Update the data of the specified row

var _data = {
	"name" : name,   
 
  
        ...//add dates
"desc" : desc
    }
$('#table_Id').bootstrapTable('updateRow', {index: index, row: _data}); // index---->update row index. row----> data to be updated

6. Update the specified column data

var rows = {
            index : index,  //更新列所在行的索引
            field : "status", //要更新列的field
            value : "正常" //要更新列的数据
        }//更新表格数据        
$('#table_Id').bootstrapTable("updateCell",rows);

7、重新加载数据(分页的时候要注意参数的传递)

var opt = {
         url: "abc.htm", //重新请求的链接
         silent: true,
         .....    //可以加一些请求的参数
        };
//重新加载数据
$("#table_Id").bootstrapTable('refresh',opt);    

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325544188&siteId=291194637
Recommended