webgrid

MVC WebGrid Set the ID rendered

≡放荡痞女 提交于 2019-12-07 14:49:48
问题 Using WebGrid from MVC 3 how do i specify the name of the control when rendered i.e. the id of the table when rendered?? var someGrid = new WebGrid(source: Model.Users, defaultSort: "Name", rowsPerPage: 50); At the moment when rendered as a table it is displaying as <table class="grid"> with no id set, i want to access this table using jQuery id selector but cant. Any help appreciated. What i want is <table id="someIDWhichIset"> Thanks Niall 回答1: when you're rendering your table is when you

Parsing Dynamic SQL in C# and binding to WebGrid in ASP.Net MVC

蹲街弑〆低调 提交于 2019-12-07 12:04:53
问题 Parsing Dynamic SQL in C# and binding to WebGrid in ASP.Net MVC I have dynamic SQL Queries that uses pivot to produce result and the resultset may be like this.: Name Div1 Div2 Div3 Div4 Div5 Active 1 0 0 0 0 Busy 0 0 0 0 1 NA 0 1 0 0 0 Suspended 0 0 0 1 0 There can be n number of divisions. I want to bind this data with ASP.NET MVC WebGrid control. I am not able to achieve this. My C# code is given below: dynamic list = db.ExecuteStoreQuery<dynamic>("exec [dbo].[proc_GetData]").ToList();

ASP.NET MVC3 WebGrid Helper and Model Metadata

房东的猫 提交于 2019-12-07 08:42:54
问题 I'm trying to use the WebGrid html helper in ASP.NET MVC 3 to autogenerate the columns according to the information found in the ModelMetadata. For example the code in a view that accepts a list of objects would be: var grid = new WebGrid(Model); @grid.GetHtml(columns: ViewData.ModelMetadata.Properties.Single.Properties .Select(p => grid.Column( columnName: p.PropertyName, header: p.ShortDisplayName ))); This actually works like a charm (I was surprised it was that easy actually). What

Filtering a WebGrid with a DropDownList in MVC4

送分小仙女□ 提交于 2019-12-06 15:44:31
I am using a WebGrid, which i bind to a List of objects containing information about deliveries. I want to be able to filter said WebGrid using a DropDownList containing Customers. When I select a Customer in the DropDownList the change-method sends an Ajax call which is supposed to get the new items for the WebGrid. The call is successful, but nothing happens. The WebGrid doesn't change at all. I even tried sending an Ajax call identical to the ones sent when sorting the list. But nothing happens. What am I doing wrong here? ViewModel: public class DeliveriesViewModel : PageViewModel

WebGrid Ajax.. how to make it work with MVC 4 W/Razor

痴心易碎 提交于 2019-12-06 14:56:05
I started working on WebGrid with MVC 4 and I able to display the paginating/sorting and its work as expected.... if i try to make it with with ajax then its doing the full post. View: - Partial View: (_hostajax.cshtml) @model IEnumerable<issoa_ef.host> @{ ViewBag.Title = "Index"; } <h2>Index</h2> <p> @Html.ActionLink("Create New", "Create") </p> @{ var grid = new WebGrid( Model, rowsPerPage: 2, defaultSort: "HostFirstName", ajaxUpdateContainerId: "ajaxgrid"); } <div id="ajaxgrid"> @grid.GetHtml( tableStyle: "gridTable", headerStyle: "gridHead", footerStyle: "gridFooter", rowStyle: "gridRow",

Problems with MVC 3 DropDownList() in WebGrid()

江枫思渺然 提交于 2019-12-06 14:31:06
问题 I'm trying to place a DropDownList inside a WebGrid but I can't figure out how to do it :( Things I've tried: grid.Column("Id", "Value", format: ((item) => Html.DropDownListFor(item.SelectedValue, item.Colors))) and grid.Column(header: "", format: (item => Html.DropDownList("Colors", item.Colors))) and grid.Column(header: "", format: Html.DropDownList("Colors")) and various others but I couldn't get it to work. Any help is much appreciated. Model public class PersonViewModel { public string

How do I get my WebGrid to POST instead of GET during a sort or paging operation in my MVC4 site?

最后都变了- 提交于 2019-12-06 11:53:56
问题 I have a fairly simple site with a Search partial view and a Listing partial view. They're rolled up using multiple models into the Index view. Everything is fine. Except when I click the grid column headers to sort or attempt to page to the next listing of data, the grid comes back empty. If I re-submit the same search criteria, then the grid repopulates with all applicable data sorted or paged properly. I've tracked this behavior down to the fact that the WebGrid sets up it's paging and

ASP.NET MVC WebGrid is not properly passing current parameters to the pagination links in a particular situation

六眼飞鱼酱① 提交于 2019-12-06 08:10:33
WebGrid pagination links work properly in all cases, except one (that I noticed). When you use CheckBoxFor in MVC, it creates an input[type=hidden] and an input[type=check-box] for the same field so that it can handle state. So, if you have a field named X and submit your form in the GET method, you will end up with an URL like this: http://foo.com?X=false&X=true The default model binder can understand these multiple instances os X and figure out it's value. The problem occurs when you try to paginate the WebGrid . It's behavior is to try catch the current request parameters and repass them in

Is the MVC WebGrid Open Source?

冷暖自知 提交于 2019-12-06 05:46:58
问题 Is the MVC WebGrid Open Source? If so where can I find the source code. The current version of the WebGrid has little to no documentation, incomplete implemtation etc. I am trying to do a simple thing as adding a visibility property to the WebGrid.Column() in the view, but that is impossible 回答1: You can download the source code of ASP.NET MVC 3 and inside you have the source of WebGrid. Once you unzip you will find it inside the webpages/src/System.Web.Helpers/WebGrid/WebGrid.cs file. Good

ASP.NET MVC3: WebGrid + Ajax Filters + Ajax Sorting & Paging

风格不统一 提交于 2019-12-06 04:19:53
问题 Basically, I'm using WebGrid and I need to filter the results. The first problem I have here is it's my first time using WebGrid and I was hoping some of you could give me a hand with it... So far, I've managed to sort grid results and filter them with Ajax, but, when re-sorting the filtered results, the subset is lost and I go back to the beginning with the full set of results. I know why it's happening of course, but I don't figure out how to make it work. Example: On my view: @model