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...