mvccontrib-grid

MVCContrib Grid - how to add and delete rows with ajax?

无人久伴 提交于 2019-12-06 04:43:20
问题 I'm wondering what's the best strategy to delete a row in MVCContrib generated grid. Consider this grid: Html.Grid(Model.Proc.Documents).Columns(column => { column.For(c => c.Name).Named("Title"); column.For(c => c.Author.Name).Named("Author"); column.For("Action").Action( delegate(DocumentDto doc) { const string cbxFrmt = "<td><strong><a href=\"#\" onclick=\"DocDetails({0})\">View details</a></strong> | " + "<strong><a href=\"#\" onclick=\"RemoveDoc({1})\">Delete</a></strong>" + "</td>";

How to use a custom column in a Mvccontrib Grid Model?

旧街凉风 提交于 2019-12-06 02:23:51
问题 I am using a ASP.NET MVC 3 Mvccontrib grid like so: @Html.Grid(Model).Columns(column => { column.For(x => x.UserId).Named("ID"); column.For(x => x.Name); column.Custom(@<div><img src='@item.ImageUrl' alt="@item.Name"/><a href="@item.Link">@item.Name</a></div>).Named("Name"); column.For(x => x.Score).Named("Score"); }) But now I need to move this into a custom grid model: @Html.MvcContrib().Grid(Model).WithModel(new MyGridModel()).Sort(ViewData["sort"] as GridSortOptions).Attributes(id =>

Overriding the default 'No Data' Message in MVCContrib Grid

自古美人都是妖i 提交于 2019-12-05 22:52:57
Is it possible to override the default 'There is no Data available' message in MVCContrib Grid with a custom message? <%= Html.Grid<SomeModelType>(Model) .Empty("Some custom message") ... %> 来源: https://stackoverflow.com/questions/3986528/overriding-the-default-no-data-message-in-mvccontrib-grid

ASP.NET MVC 4 and MVCContrib Grid: Render Checkbox for each TR and Post values in complex type

瘦欲@ 提交于 2019-12-04 22:17:24
MVCContrib Grid: @model ViewModel @using (Html.BeginForm("SendData", "Home", FormMethod.Post)) { @Html.Grid(Model.List).Columns(c => { c.For(x => x.Id); c.For(x => x.Name); c.For(x =>Html.Partial("Partial/CheckBoxTemplate", new CheckBoxViewModel { Id = x.Id })).Named("Options"); }) @Html.SubmitButton() } Controller Post Action: public ActionResult SendData(List<CheckBoxViewModel> list) { return View(); } ViewModels: public class CheckBoxViewModel { public int Id { get; set; } public bool CheckBox { get; set; } } public class ViewModel { public IPagination<Data> List { get; set; } } public

MVCContrib Grid - how to add and delete rows with ajax?

谁说我不能喝 提交于 2019-12-04 10:22:43
I'm wondering what's the best strategy to delete a row in MVCContrib generated grid. Consider this grid: Html.Grid(Model.Proc.Documents).Columns(column => { column.For(c => c.Name).Named("Title"); column.For(c => c.Author.Name).Named("Author"); column.For("Action").Action( delegate(DocumentDto doc) { const string cbxFrmt = "<td><strong><a href=\"#\" onclick=\"DocDetails({0})\">View details</a></strong> | " + "<strong><a href=\"#\" onclick=\"RemoveDoc({1})\">Delete</a></strong>" + "</td>"; Response.Write(string.Format(cbxFrmt, doc.Id, doc.Id)); } ).DoNotEncode().Named("Action"); }) .Attributes

How to use a custom column in a Mvccontrib Grid Model?

℡╲_俬逩灬. 提交于 2019-12-04 07:45:21
I am using a ASP.NET MVC 3 Mvccontrib grid like so: @Html.Grid(Model).Columns(column => { column.For(x => x.UserId).Named("ID"); column.For(x => x.Name); column.Custom(@<div><img src='@item.ImageUrl' alt="@item.Name"/><a href="@item.Link">@item.Name</a></div>).Named("Name"); column.For(x => x.Score).Named("Score"); }) But now I need to move this into a custom grid model: @Html.MvcContrib().Grid(Model).WithModel(new MyGridModel()).Sort(ViewData["sort"] as GridSortOptions).Attributes(id => "grid", style => "width: 100%;") with corresponding grid model: public class MyGridModel : GridModel

How to style rows in the MVCContrib Grid based on their data?

◇◆丶佛笑我妖孽 提交于 2019-12-02 23:51:41
I am tinkering with the MVCContrib Grid and am stuck on how to format a row of data in the grid based on the data. For example, say we have a grid of products, where each product has data fields like name, price, and discontinued. I'd like to highlight all product rows that are discontinued. One workaround would be to use jQuery on the client-side to apply a CSS class to those rows where the discontinued cell is TRUE, but that seems like a brittle solution. I'm hoping there's a way to do it on the server-side via the Html.Grid method call. Thanks Dan Ryan Hello Scott: Try something like the

Mvc Contrib grid with checkbox

可紊 提交于 2019-12-01 13:08:22
I'm looking for the way how to add a checkbox on the header that support checked or unchecked all my checkbox column of my girdview. <table class="grid"> <th><input type="checkbox" name="chkall"/></th> <th>Name</th> <tr> <td> <input type="checkbox" id="chkItem_1"/> </td> <td> Category 1 </td> </tr> <tr> <td> <input type="checkbox" id="chkItem_2"/> </td> <td> Category 2 </td> </tr> </table> column.For(x => Html.CheckBox("mycheckbox", new { @class = "foo" })) .DoNotEncode() .Header("<th><input type=\"checkbox\" id="chkHeader" /></th>"); And then you could use jquery to handle the change event of

Mvc Contrib grid with checkbox

ε祈祈猫儿з 提交于 2019-12-01 12:02:52
问题 I'm looking for the way how to add a checkbox on the header that support checked or unchecked all my checkbox column of my girdview. <table class="grid"> <th><input type="checkbox" name="chkall"/></th> <th>Name</th> <tr> <td> <input type="checkbox" id="chkItem_1"/> </td> <td> Category 1 </td> </tr> <tr> <td> <input type="checkbox" id="chkItem_2"/> </td> <td> Category 2 </td> </tr> </table> 回答1: column.For(x => Html.CheckBox("mycheckbox", new { @class = "foo" })) .DoNotEncode() .Header("<th>