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

//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,
			});
		}




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章