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
5
votes
2 answers

MVC3 WebGrid: Can htmlAttributes be used on rows/columns?

I'm using a WebGrid to create a paged/sortable list in MVC3. I've created an AJAX enabled Delete button which makes the delete call via AJAX, after which I'd like it to remove the row from the table. The way I'd like to achieve this is by having an…
Peter Bridger
  • 9,123
  • 14
  • 57
  • 89
5
votes
2 answers

MVC3 Html.BeginForm inside a WebGrid column?

I had a somewhat crazy idea earlier tonight, and got 3/4 of the way done implementing it and have run in to a weird problem.. I wanted to automatically generate an index of all methods on a controller than return an ActionResult, as well as a…
superlime
  • 906
  • 8
  • 10
5
votes
1 answer

Add a "loading" indicator in a MVC webgrid?

I am using MVC3 and displaying my data in a webgrid. I would like to display loading indicator (loading image) displayed when I filter/search. What is the best approach? My search filter (code): @using (Html.BeginForm()) {
Chaka
  • 1,709
  • 11
  • 33
  • 58
5
votes
2 answers

How to set webgrid row style inline

I am using a WebGrid to display a List of Items, some items in the list are disabled, so I would like to make it dimmed in the grid, to do that I must set the row class to be dimmed if the item is disabled, I do not know how to set the row class…
Yasser-Farag
  • 592
  • 4
  • 9
  • 28
5
votes
1 answer

Does MVC3 WebGrid support horizontal scrollbars?

I have a record set that is quite wide (about 25-30 cols)...does MVC3 WebGrid support horizontal scrollbars (or can I house the grid in a html tag/control)?
genxgeek
  • 13,109
  • 38
  • 135
  • 217
5
votes
2 answers

Populate MVC Webgrid from DataTable

I am trying to populate a MVC Webgrid using a DataTable which is built up in the code behind and then made enumerable using the AsEnumerable() extension method. However, when I call the GetHtml method, the output is not what I expect, it consists of…
tompipe
  • 949
  • 6
  • 8
5
votes
4 answers

How to change WebGrid action for getting data (.NET MVC3)

I have a Partial View that renders WebGrid. My controller looks like public ActionResult Index() { return View(); } public ActionResult GetUserList(int? page, string sort, string sortdir) { var model = UserModel.getList(page,sort,sortdir); …
a1ex07
  • 36,826
  • 12
  • 90
  • 103
5
votes
1 answer

Razor Nested WebGrid

How do I have nested WebGrid with lot of formatting for each column. I can do a nested for-loop, but I need it basically for paging. Or is there any other better option?
IsmailS
  • 10,797
  • 21
  • 82
  • 134
5
votes
4 answers

Webgrid Format of datetime and setting style

I'm struggline with syntax gremlins with the WebGrid. In my normal razor markup i format a date inside my foreach like so @String.Format("{0:MM/dd/yy hh:mm:ss}", item.complianceedatetime) and I set my column width like…
Bayrat
  • 161
  • 1
  • 3
  • 17
5
votes
2 answers

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.Columns( grid.Column("ID", "id",…
user415394
  • 303
  • 2
  • 5
  • 11
5
votes
8 answers

MVC4 WebGrid loaded from Ajax form - multiple calls to Controller when sorting and paging

I have the following in my view @using (Ajax.BeginForm("Search", "Home", null, new AjaxOptions { InsertionMode = InsertionMode.Replace, …
gyosifov
  • 3,193
  • 4
  • 25
  • 41
5
votes
5 answers

If else in Web Grid Column

How to put a condition (if else) in webgrid column? @grid.GetHtml(tableStyle: "table table-bordered", columns: grid.Columns( grid.Column("RealName", "Name"), grid.Column("UserName", "Email") …
Anup
  • 9,396
  • 16
  • 74
  • 138
5
votes
3 answers

Why can't I use my extension method in a delegate in the Razor WebGrid

I'm using the MVC 3 introduced WebGrid, but can't can't apply my own extension methods when passing a delegate for the format param. Using: Grid.Column("MyProperty", "MyProperty", format: @
Eduardo Molteni
  • 38,786
  • 23
  • 141
  • 206
5
votes
2 answers

Show Ajax Loading Indicator when sorting or paging ASP.net MVC Webgrid

I can easily hookup a webgrid and add ajax to it using the default settings. But one thing I have been struggling to figure out is how to add a loading indicator when the grid is sorting or paging via ajax. There is a built in callback function…
Rob Carroll
  • 377
  • 1
  • 7
  • 16
5
votes
3 answers

Add a class to a th

It's easy enough to add a class to a td in a webgrid, for example: new WebGridColumn { ColumnName= "Owl.Species", Header= "Scientific Name", Style= "sci-name" } The style tag adds the class "sci-name" to the td. How can I add a class to…
TheLearningDev
  • 365
  • 1
  • 6
  • 19
1 2
3
54 55