visible: function
visible: function
I need some columns to invisible if the rights are not given. I tried to do this, but that did not work.
{ targets: 8, visible: function(data, type, row){
return (data.recordRights == '1')? true : false;
}
},
I have no ideas at this time where is my fault. Have someone a idea?
Andreas
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
If
data.recordRightsis a different column then you probably wantrow.recordRightsinstead.I think you will end up with either
trueorfalsedisplayed in your column. Assuming you want to display the data if true and display a blank if false you may want to change the return to something like this:return (row.recordRights == '1')? data : '';Kevin
The
data.recordRightsis not in a column. It is a user right that are set to 1 if the User have the rights to see the column.I want the output if the rights is set to 1, they should see column 8:
and if rights set to 0, they should not see the column 8:
My Problem is the function did not work and I haven't any idea what is my failure.
Andreas
I see, misunderstood what you were doing :-)
I think you will need to use the
initComplete()to process the received data to hide the columns.EDIT: In case of processing delays a better option may be to get the permissions before initializing the table and assigning the desired configuration to a columnDefs variable. Then assign that variable to the
columnDefs.Kevin
columns.visiblecan't be given as a function. As the documentation for it notes, it should be a boolean value.If you have access to the
datavariable at that point (i.e. you are Ajax loading the data yourself, or it is Javascript sourced) you could just usevisible: data.recordRights === 1 ? true : false.Allan