Role based column visibility
Role based column visibility
Hi , i am new to the datatable plugin,
I am able to show a edit column in the table. now i want to make this column visible or generated only for some roles , which have access on the server.
How could i achieve this. Appreciate your quick response..
Thank You
MKhan
I am able to show a edit column in the table. now i want to make this column visible or generated only for some roles , which have access on the server.
How could i achieve this. Appreciate your quick response..
Thank You
MKhan
This discussion has been closed.
Replies
Allan
Thank you for your response, But i have my user roles on the server and i want to control this behavior dymanic, If you are an Admin then the column should be visible. Also If i hide it after the load will it not be available on the client Html. ?
Thank You
Mkhan
Allan
Thanks again , below is my code to load the table, The edit column i would like to place based on the role. So that for other users it is just a readonly table with no edit features..
Appreciate your help. Thank You
var oTable = $('#tbNonClinList').dataTable({
"oLanguage": {
"sSearch" : "Search all columns:"
},
"bServerSide": true,
"sAjaxSource": "Home/NonClincalMapListAll",
"fnServerData": fnDataTablesPipeline,
"bProcessing": true,
"bPaginate": true,
"sPaginationType": "full_numbers",
"aoColumns": [
{ "sName": "Id",
"bSearchable": false,
"bSortable": false,
"fnRender": function (oObj) {
return 'Edit';
}
},
{ "sName": "PlwWpkCodeDesc" },
{ "sName": "WpkFunction" },
{ "sName": "FdrActivityTypeDesc" },
{ "sName": "EtActivityCodeDesc" },
{ "sName": "Active", "bSearchable": false, "bSortable": false, "sWidth": "20px" },
{ "sName": "ModifiedUser", "bSearchable": false, "bSortable": false },
{ "sName": "ModifiedDate", "bSearchable": false, "bSortable": false }
],
"sDom": '<"H"fr>tC<"F"ip>',
"bJQueryUI": true,
"sScrollY": "450px",
"bScrollCollapse": false,
"bScrollAutoCss": true,
"aoColumnDefs": [
{ "bVisible": false, "aTargets": [2,6,7] }
],
"oColVis": {
"buttonText":"#",
"bRestore": true,
"sAlign": "Left"
},
"fnDrawCallback": function (o) {
/* Position the ColVis button as needed */
var nColVis = $('div.ColVis', o.nTableWrapper)[0];
nColVis.style.width = o.oScroll.iBarWidth + "px";
nColVis.style.top = ($('div.dataTables_scroll', o.nTableWrapper).position().top) +"px";
nColVis.style.height = ($('div.dataTables_scrollHead table', o.nTableWrapper).height()) + "px";
}
});
Could you please let me know , how i can achieve the dynamic column generation.
Appreciate your help..
Thank You