Questions tagged [webgrid]

WebGrid is a view control built in to the ASP.NET Web Pages Framework. It displays a sortable, pageable HTML grid given a collection, and is customizable in various ways, making use of .NET 4.0's "dynamic" object type.

The ASP.NET Web Pages WebGrid provides a kind of quick-scaffolded functionality for displaying tabular information in ASP.NET Web Pages, or ASP.NET MVC when using the Web Pages (Razor) view engine. Given an IEnumerable data source, it is possible to construct a functional HTML data table, with sorting and paging, with a single line of code in the View (Razor syntax, for example):

@( new WebGrid(data).GetHtml() )

The control offers customization of various styling, sorting, and paging functionality; as well as the ability to define the column contents either as raw data, or as templated HTML.

822 questions
3
votes
3 answers

Custom message inside the webgrid if empty

@if (Model.ActivityCollection.Count > 0) { var grid = new WebGrid(source: Model.ActivityCollection, rowsPerPage: 12, canSort: false); @grid.GetHtml(tableStyle: "webGrid", headerStyle: "header", …
TJK
  • 441
  • 4
  • 11
  • 27
3
votes
2 answers

How to vary the class of a TD on MVC3 WebGrid generated output?

I am using the MVC3 WebGrid (Razor) and everything is working fine. However, I need to vary the css class that is attached to a particular column based on the value that is in the column. I have a non-Server-side JQuery way of doing this already.…
Jay Stevens
  • 5,863
  • 9
  • 44
  • 67
3
votes
4 answers

add row in webgrid

I'm working with MVC 3 webgrid and i need to add a new row into webgrid to show sum of price from product table. Any ideas are appreciated. Here's my code @{ WebGrid grid = new WebGrid(source: Model, rowsPerPage: 3, …
lct_005
  • 65
  • 3
  • 10
3
votes
1 answer

MVC3 WebGrid - Row Id

How can you specify the row id or class with a specific id? Or even this is ok I was thinking something like this would work but it doesn't. @grid.GetHtml( rowStyle: "row_" + grid.Column(columnName:…
fes
  • 2,465
  • 11
  • 40
  • 56
3
votes
1 answer

Header Format for WebGrid

I just read: http://www.mikesdotnetting.com/Article/154/Looking-At-The-WebMatrix-WebGrid and see a reference to [Optional, Default Value(null)] string header Header text if you don't want database field names But I'm not sure how to format cell…
anon271334
3
votes
1 answer

MVC WebGrid - How to programatically get the current page, sort column etc

How can I programatically (in javascript) get the current page number, last sort column and sort direction of the ASP.NET MVC WebGrid? Is it possible to update the arguments before it calls the $("#grid").load() method?
Tawani
  • 11,067
  • 20
  • 82
  • 106
3
votes
1 answer

How can I hide a WebGrid column based on the current user's role?

I need to do a grid using webgrid and I would like to hide the column (header and items) of edit actions based on user role. How can I do that with webgrid?
Cleyton T.
  • 33
  • 1
  • 3
3
votes
1 answer

DropDownListFor in ASP.NET MVC 3 WebGrid

I have a WebGrid that I'm creating and I want a dropdownlist in there - I can't find a way to make one of the rows a DropDownList - any tutorials out there? Right now i've been trying to use the "format:" setting to set it up - but I keep getting…
Aaron
  • 31
  • 3
3
votes
5 answers

Defining inline row style in System.Web.Helpers.WebGrid

I am moving my application to MVC 3 and try to use System.Web.Helpers.WebGrid. I would like to get html code like: …
LukLed
  • 31,452
  • 17
  • 82
  • 107
3
votes
4 answers

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 = new WebGrid(dq, rowsPerPage: 50, defaultSort:…
Knox
  • 2,909
  • 11
  • 37
  • 65
3
votes
4 answers

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…
Antonin Jelinek
  • 2,277
  • 2
  • 20
  • 25
3
votes
1 answer

How display two columns in Mvc WebGrid with single object

I am new to MVC and I want to display name of a user in two columns in a WebGrid as display below. Currently the web grid display data in below format. I am binding my WebGrid with List, list contains username. My Controller public…
user2071882
3
votes
1 answer

Displaying automatically generated SQL code from column sorting

I would want to be able to display those automatically generated SQL code on the database web page, when doing a primary sorting on a specific column in web grid. For Instance, if you click on any column header on a database web page, the selected…
Phantom
  • 443
  • 1
  • 5
  • 15
3
votes
2 answers

Live search on a web grid table with pagination working only on the actual page

I want to implement a live search on a web grid table which has pagination. However, my search only shows elements which are present in the actual page. I want my search function to do a search on all the element present in the table. Not only the…
refresh
  • 1,319
  • 2
  • 20
  • 71
3
votes
1 answer

IEnumerable OrderBy by String with complex property

I need to sort a query by string and found this that works well. The problem is that it can't handle complex properties related entities such as "ComplexProperty.Property""RelatedEntity.Property" since it only searches the main class. I'm thinking I…
Trixz
  • 190
  • 13