This is a migrated thread and some comments may be shown as answers.

Maybe Off Topic, but I am curious...

2 Answers 22 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Joe
Top achievements
Rank 1
Joe asked on 22 Dec 2016, 04:22 PM

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 Answers, 1 is accepted

Sort by
0
Joe
Top achievements
Rank 1
answered on 22 Dec 2016, 04:32 PM
Never mind.. after giving it some more thought, the answer dawned on me... it's not really as mysterious as I thought...
0
Kiril Nikolov
Telerik team
answered on 26 Dec 2016, 07:10 AM
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.
Tags
General Discussions
Asked by
Joe
Top achievements
Rank 1
Answers by
Joe
Top achievements
Rank 1
Kiril Nikolov
Telerik team
Share this question
or