Issue with RadioGroupFor .ToClientTemplate (2023.2.718 buid)

1 Answer 100 Views
RadioGroup
Michael
Top achievements
Rank 2
Iron
Iron
Iron
Michael asked on 20 Jul 2023, 08:00 PM

I'm trying to add a RadioGroupFor control to a Toolbar control as a templated item but am getting a JS error related to the generated client template.

Here is the template definition:

<script id="ApproveOrDenyTemplate" type="text/x-kendo-template">
    @(Html.Kendo().RadioGroupFor(model => model.ApproveOrDeny)
        .Layout(RadioGroupLayout.Horizontal)
        .HtmlAttributes(new { style = "display: inline-flex; vertical-align: top;" })
        .LabelPosition(RadioGroupLabelPosition.After)
        .Items(i =>
        {
            i.Add().Label("Approve").Value("Approve");
            i.Add().Label("Deny").Value("Deny");
        })
        .Events(e => e.Change("changeApproveOrDeny"))
        .ToClientTemplate()
    )
</script>

Here is the Toolbar templated item entry:

items.Add()
    .TemplateId("ApproveOrDenyTemplate")
    .Hidden(!Model.ShowApprovalRadioGroup);
Here is the error being thrown and the generated client template javascript (the bold red code is what shows as offending text in console.log) - have I defined the template wrong or is the toolbar item entry wrong?
VM48:1 Uncaught SyntaxError: Unexpected token '<'
kendo.syncReady(function(){jQuery("\#ApproveOrDeny").kendoRadioGroup({"change":changeApproveOrDeny,"items":[{"label":"Approve","value":"Approve"},{"label":"Deny","value":"Deny"}],"value":"Approve","layout":"horizontal","labelPosition":"after"});});<\/script>

1 Answer, 1 is accepted

Sort by
1
Accepted
Alexander
Telerik team
answered on 25 Jul 2023, 12:16 PM

Hi Michael,

Upon further examination, it appears that the issue may potentially stem from the fact that the ".ToClientTemplate()" is utilized within the RadioGroupFor component. Omitting the API configuration seems to render the component accordingly:

For your convenience, I am also attaching a runnable sample that tackles the latest version of the Telerik UI for ASP.NET Core suite for you to observe and experiment in more depth.

Please let me know how it works out for you.

Kind Regards,
Alexander
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages. If you're new to the Telerik family, be sure to check out our getting started resources, as well as the only REPL playground for creating, saving, running, and sharing server-side code.
Michael
Top achievements
Rank 2
Iron
Iron
Iron
commented on 25 Jul 2023, 12:43 PM

I can confirm this does indeed resolve the issue - thanks for providing the solution.
Tags
RadioGroup
Asked by
Michael
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Alexander
Telerik team
Share this question
or