hide coloum responsive with match condition

hide coloum responsive with match condition

deromaderoma Posts: 1Questions: 0Answers: 0

i have 10 coloums in table responsive mode.
i would like to have these conditions:
if user= x hide 5 coloum and visibile rest of coloum;
if user= y hide 3 coloum and visible rest coloum;

how can i do that?

thank you very much
Fabio

Replies

  • lecleardlecleard Posts: 9Questions: 2Answers: 1
    edited April 2017

    Well, however you're storing your user id, just do a condition check on the user variable and use the column(n).visible( true or false);

    $(document).ready(function() {
      var user = "Y";
      var table = $('#example').DataTable( {
      });
      
      if ( user == "X" ) {
        table.column( 4 ).visible( false );
      }
      else if ( user == "Y" ) {
        table.column( 2 ).visible( false );
      }
    });
    

    Here's a jsfiddle example. jsfiddle.net/lecleard/u0Lfez1j/

This discussion has been closed.