mvccontrib

MvcContrib Grid Sorting on complex object

爷,独闯天下 提交于 2019-12-04 11:13:55
I am trying to work with MvcContrib Grid control. But I cannot seem to get the sorting to work on complex objects that hold other objects. I have setup my controller/classes/Views similar to the OP in this question. Sorting with MVCContrib I have tried to use the SortColumnName to my childobject.property but it gives me an error saying My main object does not have this property. This is my code snippet //POCO class class Issue { public int ID {get; get; } ..... public int priorityId {get; set;} public virtual Priority priority {get; set;} } //Controller code public ViewResult Index(int? pageNo

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

Integration testing an MVC application without the pain of UI automation

ぐ巨炮叔叔 提交于 2019-12-03 17:15:42
I'm starting development on a new MVC application that will be largely written using TDD. I'd like to add some integration tests to ensure that the fully wired application (I'm using StructureMap for IOC, NHibernate for persistence) works as expected. While I intend to write a few functional smoke tests with Selenium, for maintainability reasons, I'd rather do my most of integration testing by directly calling actions on my controllers using good old C#. There is surprisingly little guidance on how one would accomplish this, so I took a stab on a plan of attack Pull all bootstrapping code out

Html.Grid right align data in column

本秂侑毒 提交于 2019-12-03 15:42:49
In an Html.Grid, how can we ensure that data in the column (e.g. currency amounts) gets right aligned? Thanks. You mean in the MvcContrib Grid? You could use something like: column.For(x => x.Amount).Attributes(style => "text-align:right"); or more tidily you could set a class: column.For(x => x.Amount).Attributes(@class => "right-align"); and set an appropriate style rule on that class. Here's what worked for me. Within the grids htmlAttributes assign the resulting table an id. In this example "gridT". In the CSS create a style for "#gridT", for the second column to align the text left. @grid

Does .NET MVC have a strongly typed RedirectToAction?

家住魔仙堡 提交于 2019-12-03 06:56:05
问题 Since I have decided to let RC go while staying with Beta for now, I have no way of knowing whether a strongly typed RedirectToAction has been added. Has anybody tried it and is there a strongly typed RedirectToAction (and maybe ActionLink ) in RC? 回答1: No, it doesn't. protected RedirectToRouteResult RedirectToAction<T>(Expression<Action<T>> action, RouteValueDictionary values) where T : Controller { var body = action.Body as MethodCallExpression; if (body == null) { throw new

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>

Use MVCContrib grid for editing

僤鯓⒐⒋嵵緔 提交于 2019-11-30 02:41:31
I just started using the MVCContrib grid in a test project. I'm having a difficult time finding information on how to use it for edit/update/delete. Can anyone point me to information on how to put a row into edit mode, or if there isn't such a thing for that grid, discuss a best practice for editing list data in MVC. It appears as if MVCContrib is a simple way to construct the HTML Table from a collection of model objects. It doesn't appear as if has any ability to put a row into edit/update/delete "mode" similar to the WebForms GridView. However, it does look like you can handle that

ASP.NET MVC 3, Razor Views, and Portable Areas

。_饼干妹妹 提交于 2019-11-29 21:05:37
I am trying to using portable views with ASP.NET MVC 3 and razor views as that seems like the best way to create an easy plug-in architecture. So I have my class library setup and I have my view located in /Views/Admin/Index.cshtml and it is set as an Embedded Resource. I then include that project as a dependency for the main web application project. When I try to access the Admin controller, Index action I get a message that is can't find that view file (so the controller is being properly included). I am assume it is trying to look in the main web application project and not the portable