bootstrapTable hides a column based on a condition

When we use bootstrapTable, we sometimes need to hide a column according to conditions, such as permissions

{
	field : 'id',
	title : 'Operation',
	width : 80,
	align : 'center',
	formatter : function(value, row, index) {
		var operation = "";
		// approve
		if (!$.string.isNullOrWhiteSpace($(
				"#btn_approval").val())) {
			operation += "<a href='javascript:void(0);' id='approval'>审核</a>";
		}
		return operation;
	},
	events: { 'click #approval' : function (e, value, row, index) {
		   toEncodeUrlPage(mw.ctx+ "/sbas/org/manageDetail?id="+row.orgId+ "&userId="+row.id);
		}
	}
}],
onLoadSuccess: function(){ //Execute when the load is successful  
	if($.string.isNullOrWhiteSpace($("#btn_approval").val())){
		$('#tb_org').bootstrapTable('hideColumn', 'id');
	}
}

onLoadSuccess : function(){ //Execute when the load is successful  
if($.string.isNullOrWhiteSpace($("#btn_approval").val())){
          $('#tb_org').bootstrapTable('hideColumn', 'id');
     }
}

id is the field value of that column

Guess you like

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