[英]Dynamically adding column to grid using Jquery Datatable and Spring
I want to add column dynamically based on the condition of the attribute that i am passing from the controller to view.I am using Jquerydatable for grid view and Spring as a framework. 我想根据我从控制器传递给视图的属性的条件动态添加列。我正在使用Jquerydatable进行网格视图和Spring作为框架。 I tried various to search solution but nothing seems to work.So can anyone suggest any solution to add a column dynamically only if the passed attribute satisfy the condition. 我尝试了各种搜索解决方案,但似乎无济于事,因此任何人都不能建议任何解决方案以仅在传递的属性满足条件的情况下动态添加列。 Thanks. 谢谢。
May be use javascript 可能使用javascript
oColumns = [{ "mData": "id", "bVisible": 0 }]; // by default I set ID column
columns = ["name", "email", "phoneNumber"]; // can initalize from server
${id}_columns.forEach(function(entry) {
col = [{"mData": entry}];
${id}_oColumns = ${id}_oColumns.concat(col);
});
oTable = $('#$datatable').dataTable({
"bProcessing": true,
"sAjaxSource" : "rest",
"aoColumns": oColumns,
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.