Reputation: 275
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")
Upvotes: 0
Views: 2329
Reputation: 17
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();
}
Upvotes: 0
Reputation: 1476
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.
Upvotes: 2