webgrid

Razor webgrid ajax paging and sorting

て烟熏妆下的殇ゞ 提交于 2019-11-28 04:22:51
I'm trying to learn how to use Razor WebGrid in MVC3. How does the ajaxUpdateCallback parameter work? The ajaxUpdateCallback is the name of the javascript function that will get called after the server call is complete. The title of your question is regarding paging and sorting with the WebGrid which would look something like this... @{ var grid = new WebGrid(canPage: true, rowsPerPage: ThisController.PageSize, canSort: true, ajaxUpdateContainerId: "grid"); grid.Bind(Model.Employees, rowCount: Model.TotalRecords, autoSortAndPage: false); grid.Pager(WebGridPagerModes.All); @grid.GetHtml

Filter is getting lost in WebGrid + Paging + Sorting + Filtering in .NET 4.0

試著忘記壹切 提交于 2019-11-27 22:55:01
I've implemented a WebGrid. Sorting, paging and filtering do not work together. They work when you use them alone. When you combine the three, at the same time, filtering doesn't work. The symptom: Filter the resultset, then sort. or Filter the resultset, then go to next page. In both cases, the filter is lost. But it does page and sort. In the code behind: When the action method is called via a sort or pagination, nulls show for each of the filter parameters. When the action method is called via the filter, the filter parameters come through. This tells me that when you initiate a sort or a

Conditionally display an image in webgrid - mvc 3

允我心安 提交于 2019-11-27 15:03:14
问题 In my webgrid I need to display images based on the value .. Code is given below @model TraktorumMVC.Models.ManagePhotos @{ ViewBag.Title = "ManagePhotos"; Layout = "~/Views/Shared/_Layout.cshtml"; var grid = new WebGrid(Model.AdPhotos); } @grid.GetHtml( displayHeader: false, columns: grid.Columns( grid.Column(format: (item) => { if (item.IsMainPreview == true) { return @<text><img src="@Url.Content("~/Content/images/preview-photo.gif")" alt="Image "/></text>; } else { return @<text><img src=

Mvc 3 texbox in webgrid (razor)

房东的猫 提交于 2019-11-27 06:11:16
问题 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: "FirstName",rowsPerPage: 3); } <div id="grid1"> @grid.GetHtml(columns: grid.Columns( grid.Column("LastName"), grid.Column(format: (item) => Html.TextBox("LastName", item.LastName)) )) </div> 回答1: Extension methods (i.e., Html.TextBox) don't work well with dynamic objects (i.e., item)... it's a limitation of c#

How to use WebGrid in a cshtml view?

ぐ巨炮叔叔 提交于 2019-11-27 02:48:02
问题 I am able to use WebGrid in any controller like: var grid = new WebGrid(emailsFetched, columnNames); I had to add a reference in my ASP.NET MVC project to System.Web.Helpers for this. But when I try to use this web grid in view directly (to avoid instantiation and other settings in controller) it says: The type or namespace 'WebGrid' cannot be found . Ok, I tried to add a reference here too: @using System.Web.Helpers but this throws another issue: There is no build provider registered for the

Using data in a HTML.ActionLink inside a WebGrid.column, not possible?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-27 01:34:53
问题 I have the following WebGrid in my ASP.NET MVC3 test application. It displays a list of customers: @grid.GetHtml( tableStyle: "grid", headerStyle: "head", alternatingRowStyle: "alt", columns: grid.Columns ( grid.Column(format: (item) => Html.ActionLink("Edit", "Details", new { id = item.id })), grid.Column("Address.CompanyName"), grid.Column("Address.City") ) ) The interesting part here is the Edit-link I've added in the first column. I would like to use the customers account number instead

Razor webgrid ajax paging and sorting

帅比萌擦擦* 提交于 2019-11-27 00:28:08
问题 I'm trying to learn how to use Razor WebGrid in MVC3. How does the ajaxUpdateCallback parameter work? 回答1: The ajaxUpdateCallback is the name of the javascript function that will get called after the server call is complete. The title of your question is regarding paging and sorting with the WebGrid which would look something like this... @{ var grid = new WebGrid(canPage: true, rowsPerPage: ThisController.PageSize, canSort: true, ajaxUpdateContainerId: "grid"); grid.Bind(Model.Employees,

MVC 3 Webgrid - how do you hide columns you do not want to be visible?

ⅰ亾dé卋堺 提交于 2019-11-26 22:51:10
问题 I have a webgrid and there is a column I want to be visible only to certain users. Currently I have coded the grid as follows if (Context.User.IsInRole(Role.Inputter) || Context.User.IsInRole(Role.Administrator)) { @grid.GetHtml(columns: grid.Columns( grid.Column(format: (item) => Html.ActionLink("Select", "Details", new { contractId = item.ContractId })), grid.Column(format: (item) => Html.ActionLink("Edit", "Edit", new { contractId = item.ContractId })), grid.Column("SignOffDate", "Sign Off

Razor Nested WebGrid

醉酒当歌 提交于 2019-11-26 16:56:22
问题 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? 回答1: Excuse the verbose data setup but this works... @{ var data = Enumerable.Range(0, 10).Select(i => new { Index = i, SubItems = new object[] { new { A = "A" + i, B = "B" + (i * i) } } }).ToArray(); WebGrid topGrid = new WebGrid(data); } @topGrid.GetHtml(columns: topGrid.Columns( topGrid.Column("Index"), topGrid.Column(