Maybe Off Topic, but I am curious...

3 posts, 0 answers
  1. Joe
    Joe avatar
    173 posts
    Member since:
    May 2012

    Posted 22 Dec 2016 Link to this post

    I have created a few HtmlHelper extension methods that we use is different projects at my company, but they've usually been single level type of method calls, with a variable list of parameters.  But how does Kendo create the HTML Helpers such as those found in the Telerik MVC collection, with nested method calls?

    For example, I've easily create a razor helper that parses a session variable for Claim data, and return the appropriate claim value based on the type.  Such as 

    @{
        ViewBag.Title = "Vensure.Dashboard.App";
     
        string FullName = Html.GetClaimValue("fullname");
        bool isAdmin = Html.GetClaimValue("app-roles").Contains("admin");
    }

     

    But the Kendo components typically have multiple methods extending the initial method.  Such as:

    @(Html.Kendo().DropDownList()
            .Name("availableClients")
            .DataTextField("ClientName")
            .DataValueField("ClientId")
            .DataSource(ds => ds.Read("GetClientList", "Mapping"))
            .Template("<span class=\"k-state-default\">#: data.ClientId # - #: data.ClientName #</span>")
            .ValueTemplate("<span class=\"selected-value\">#:data.ClientId# - #:data.ClientName#</span>")
            .HtmlAttributes(new { style = "width: 100%" })
            .Events(e => e.Change("clientChange"))
            .OptionLabel(" -- Select Client --")
            .Height(400)
        )

     

    I'm just curious as to what the HtmlHelper extension code looks like to support the .Method().OtherMethod().YetAnotherMethod() nested syntax...

  2. Joe
    Joe avatar
    173 posts
    Member since:
    May 2012

    Posted 22 Dec 2016 in reply to Joe Link to this post

    Never mind.. after giving it some more thought, the answer dawned on me... it's not really as mysterious as I thought...
  3. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2598 posts

    Posted 26 Dec 2016 Link to this post

    Hi,

    I am happy to hear that the issue is resolved. In case you have any further questions - do no hesitate to contact us.


    Regards,
    Kiril Nikolov
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top