bootstrap-table的行数据使用array和json的区别

来源:互联网 发布:网络监控机多少钱 编辑:程序博客网 时间:2024/06/05 10:20
//bootstrap-table中的data参数传的只能是数组数据,json数据不行,通过url参数传数据时,可以传json数据,但此时还需要配置参数
responseHandler: function (res) {
return res.rows;

}

返回json数据中的行数据数组,所以最终使用的还是json中的数组。可通过

Object.prototype.toString.call(newData).toLowerCase()

判断数据是数组还是json对象,数组添加新数据不知道数组索引的情况下可以使用push()函数,


if(devType == "信号机"&&unit=="A单位") {var newData = [];for(var p in wcssdata) {console.log(wcssdata[p]);if(wcssdata[p].type == devType&& wcssdata[p].maintain_unit==unit) {newData.push(wcssdata[p]); //给数组添加新对象数据//newData[0]=wcssdata[p];}}console.log(newData)console.log(Object.prototype.toString.call(newData).toLowerCase())//[object array]console.log(Object.prototype.toString.call(wcssdata).toLowerCase())$("#table").bootstrapTable('refreshOptions', {data: newData,});}




原创粉丝点击