搜索
您的当前位置:首页正文

bootstrap-Table 根据条件动态生成表格数据

来源:独旅网

根据条件的不断改变 来更新bootstrap-Table表格
我用的是select每次onchagne()方法 每次改变触发一次ajax请求
效果图:选了第一仓库

$.ajax({
	url:"后端请求地址",
	type:"post",
	data:{
		"storeId":ckId,
		"positionId":cwId,
		"shelvesId":hjId,
		"attributeName":typeName
	},
	success:function(res){
		//res是JSON数组格式[{"id":"1","name":"1"},{"id":"2","name":"123"}]
		var dataJson = eval('(' + res + ')');//这个方法必写 否则拿不到值
		// console.log(dataJson);
		/* .bootstrapTable('destroy')一定要加  可以不加试试看效果 */
		$('.kccx_table').bootstrapTable('destroy').bootstrapTable({
		  // url: "../json/ckdy.json", 
		  data:dataJson,  
		  dataType:'json',
		  search: true,
		  pagination: true,
		  buttonsclass: 'info',
		  pageNumber:15,
		  showRefresh: true,
		  showToggle: true,
		  //striped: true, /* 间行显示*/
		  /* onClickRow:function(row, $element,field){
					  var i = $element.data('index');//可通过此参数获取当前行号
					  alert(i+","+row.age+","+field);
				  }, */
		  sortable: true,/* 排序 */ 
		  // buttonsAlign:"left",
		  exportTypes: ['json', 'xml', 'csv', 'txt', 'sql', 'excel'],
		  showColumns: true,
			clickToSelect: true, //是否启用点击选中行
		  iconSize: 'outline',
		  toolbar: '#btnGrp_adjh',
		  icons: {
			refresh: 'glyphicon-repeat',
			toggle: 'glyphicon-list-alt',
			columns: 'glyphicon-list'
		  }
		});
	}
})

因篇幅问题不能全部显示,请点此查看更多更全内容

Top