Hide Columns in a DataTable

Hello Again

I have a quick question on how to hide columns in a DataTable.

i need to hide the checkbox and the Edit button within a row.

I managed to do so already this much:

  • Removed the first and second header

    $($(dt.$el).find('.k-header')[0]).hide();
    $($(dt.$el).find('.k-header')[1]).hide();

  • removed the edit and checkbox but somehow the column where the checkbox is in is still there:

      $(dt.$el).find('.k-checkbox').hide();
      $(dt.$el).find('.fd-command-cell.k-command-cell').hide();
    

image image

i think i may be using the wrong class but within a row there is no class to adress, with exception of the command-cell class, which shows the pencil. all the other columns are just "roles" which probably explains why only the checkbox is gone and not the field itself. is there another approach to adress roles instead of classes?

image

I found the Solution.
Instead of adressing the single cells in the table i'm hiding just the whole columns with this code:

Like this, one can target whichever column you want.
with td for the cell itself and th for the header

    $('td:nth-child(1),th:nth-child(1)').hide();
    $('td:nth-child(2),th:nth-child(2)').hide();
1 Like