display the column only if it's provided by json
display the column only if it's provided by json
foxmedo
Posts: 19Questions: 3Answers: 0
hello,
i have a level access to the information for example for clients list i need to display the turnover of the client for some user and hide it for others.
also i need it to display delete date for the administrator only for the administrator which can recover the information from soft delete.
any idea ? to control this using json ??
FYI i already use a colvis to display and hide columns
B.R
This discussion has been closed.
Answers
I would recommend controlling this with your server side query. If you return the data in your JSON it is available at the client for someone to find even though you might not display the column. For example I could just look at the developer tools and view the JSON response.
Kevin
exactly this what i want to do, but at the same time i want to hide the column from the datatable, so if i don't provide the information into the json the datatable will not design the column.
i don't want datatable to display the name of the column into the colvis and i don't want to see the column empty.
if the columns exist on my json datatable will design it else this columns doesn't exist
Ok, I think I understand what you are asking for. You want the ability to dynamically build the columns based on the data returned. You can do this with an external ajax call then in the success function you can build the columns. Your server response can contain explicit column info or you can derive it from the fields returned. This example derives the column info from the fields returned:
http://live.datatables.net/huyexejo/1/edit
Note the use of
columns.title
to build thetable
headings.Is this what you are looking for?
Kevin