Antonin Jelinek
Antonin Jelinek

Reputation: 2317

How to hide header on MVC3 WebGrid

Is there some easy way to hide header for MVC3 WebGrid extension? Something like

 var grid = new WebGrid(Model, canSort:false, canPage:false, showHeader:false);

I can probably set css style for header that will cause header not showing, though I'd rather have this done via code.

Thanks,

Antonin

Upvotes: 3

Views: 9805

Answers (4)

Thomas Fonseca
Thomas Fonseca

Reputation: 542

If you are trying to hide the header but still show the column of data just make the header a single blank space:

 grid.Column("Address2", header: " ", style: "cols", canSort: true) 

Upvotes: 0

Praveen S
Praveen S

Reputation: 650

Use this code to hide column with its header Value: WebGrid

grid.Column(null,null, format: @<input type="hidden" name="IDHidden" value="@item.IDHidden"/>),

Upvotes: 0

akruwala
akruwala

Reputation: 1

write down column index in eq() and it will work put this in document.ready() function

$('.grid table thead tr th:eq(8)').hide();

Upvotes: 0

Darin Dimitrov
Darin Dimitrov

Reputation: 1039548

You could pass it to the GetHtml method:

@grid.GetHtml(displayHeader: false)

For additional options you may take a look at the following blog post.

Upvotes: 14

Related Questions