Edit Links in GridModel (MVCContrib)

MvcContrib GridModel: is it possible to make ActionSyntax in GridModel I read this article and it is very useful, but I can not apply it. I do not know if ".Action ()" has been deleted in the new MVCContrib, because somehow I cannot access it.

Is there any way to put the ActionLink link of an edit link in a mesh model?

thanks

+5
source share
3 answers

It seems that the old method is removed.

Here's how to do it now:

Vb.net

Html gridmodel , gridmodel.

Imports MvcContrib.UI.Grid

Public Class PersonGridModel
    Inherits GridModel(Of Person)

    Public Sub New(ByVal html as HtmlHelper)
        Column.For(Function(u) html.ActionLink("Edit", "Edit", "Person", New With {.id = u.PersonId}, Nothing)).DoNotEncode()
    End Sub
End Class

, , :

<%=Html.Grid(Model).WithModel(New MemberRetentionTrackingSystem.InboundCallGridViewModel(Html))%>

#

GridModel:

public class PersonGridModel : GridModel {
    public PersonGridModel(HtmlHelper html) {
        Column.For(u => html.ActionLink("Edit", "Edit", "Person")).DoNotEncode();
    }
}

:

< %= Html.Grid(ViewData.Model).WithModel(new PersonGridModel(Html)) %>

: http://www.jeremyskinner.co.uk/2009/02/22/rewriting-the-mvccontrib-grid-part-2-new-syntax/ (. Amitabh)

+4

, ,.DoNotEncode() , .Encode(false)

+1

-, @ : . ASP.NET MVC 4 , Grid- :

Column.For(hospital => html.ActionLink("View Details", "Show", "Foo")).Encode(false);

? :

using System.Web.Mvc.Html;

I used only this using Visual Studio Intellisense:

using System.Web.Mvc;

Hope this helps anyone who is facing the same problem!

0
source

All Articles