English 中文(简体)
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

最佳回答

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.

问题回答

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

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

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

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

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) 




相关问题
How to change the default sort order to descending?

How do I change the defaultSort of my webGrid to be in the opposite/descending order? If it were SQL, I d be adding a DESC somewhere. Here s my working line of code for an Ascending sort: var grid =...

MVC 3 Webgrid Column

I m working on a MVC 3 webgrid at the moment, in one of the columns I wish to have a button, I ve achieved this when putting the following code in the view. @grid.GetHtml(columns: grid....

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 ...

asp.net mvc 3 webgrid sorting remains ?sortdir=ASC

I m experimenting a bit with several grids in asp.net mvc. Microsoft has a grid too know in the prerelease of mvc 3 so I thought I ll try that one out. The basic functionality is quite easy to ...

How to make a MVC 3 Webgrid with checkbox column?

The code below will insert an actionlink into one of the web grids columns. @{ View.Title = "Index"; Layout = "~/Views/Shared/_Layout.cshtml"; var usersGrid = new WebGrid(source: ...

Mvc 3 texbox in webgrid (razor)

Simple Q:How do you I get the textbox to show the value. Code below fail on item.LastName @model List<Mvc2010_11_12.Models.Employee> @{ var grid = new WebGrid(source: Model,defaultSort: "...

ASP.NET MVC 3 WebGrid paging issue

My data access layer returns collection with rows for single page and total number of rows. Unfortunately WebGrid component does not allow to specify total number of rows or total number of pages (...

热门标签