The WebGrid Helper allows you to apply the CSS class to individual columns using the style
property. Unfortunately, while this allows you to hide the column inside the tbody
section, you cannot apply different styles to the column headings. You can apply the same style to all columns, which makes it pretty useless. So one of the possibilities is to use CSS:
table th:first-child, table td:first-child { display: none; }
It is assumed that you want to hide the first column and that the client browser supports the :first-child
pseudo-selector, which may not be with legacy browsers.
So, if you need to support legacy browsers, you can use jQuery to apply a hidden style to the header and rows of the first column, or just hide them directly:
$(function () { $('table th:first-child, table td:first-child').hide(); });
If you want more control, I would recommend you check out the MvcContrib Grid or Telerik Grid .
source share