0

How can I hide a column in a webgrid? I should be able to access those values from the grid but the user should not be able to see the column in the grid. There is no condition, but completely I want to hide those columns

My column is

grid.Column(header: "Phone")
Bart
  • 19,692
  • 7
  • 68
  • 77
always v
  • 275
  • 1
  • 3
  • 9

2 Answers2

2

Probably the easiest way is to just use some CSS/jQuery where 'TABLECLASS' is the name of your table's class:

table.TABLECLASS th:first-child, table td:first-child {
    display: none;
}

I do not think there is a way to do this via the built in WebGrid.

Chris Knight
  • 1,448
  • 1
  • 15
  • 21
0

If you want to hide the 2nd column, for instance:

  $(document).ready(function()
  {
  $("#yourGridId th:nth-child(2)").hide();
  $("#yourGridId td:nth-child(2)").hide();
  }
Ashwini Nayak
  • 17
  • 1
  • 6