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

How to get PanelBar to submit the form with a parameter

1 Answer 176 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 22 Sep 2012, 03:00 AM
I thought i would use the PanelBar because it looks good.
But can't find any real info on how to actually use it.

I need it to set a parameter in my model and then to submit the form/page.

I used to use a bunch of radio buttons like this:
@foreach(var item in Model.Years)
    {
        <div class="YearRadio">
            <label>@item.Name</label>
            @Html.RadioButtonFor(x => x.CurrentYear, item.Id.ToString(),new { onchange = "this.form.submit();" })
        </div>
    }

And thought i would replace them with a nice panelbar something like this:

@(Html.Kendo().PanelBar()
            .Name("panelbar-Years")
            .ExpandAll(true)
            .Items(panelbar =>
            {
                panelbar.Add().Text("Years")
                    .Items(africa => {
                        foreach (var item in Model.Years)
                        {
                            africa.Add().Text(item.Title);
                        }
                    });
            })
        )
I found an action method on the panel bat, but it is unclear how to get it to simply action the default action. Also, don't know hot to bind or send the information to my model. Perhaps i could pass it to my controller as a variable or something.

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 26 Sep 2012, 11:05 AM
Hi Andrew,

The PanelBar cannot submit information about its selected item, because it does not contain form elements and fields. You can use the widget's select event and populate a hidden field outside the PanelBar. Note that this approach does not boast the greatest possible accessibility, as it relies on both Javascript and CSS.

You can make a PanelBar item call an action method on click by specifying the item's Url() or Action() or Route(). This will make the item render a hyperlink.

Regards,
Dimo
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
PanelBar
Asked by
Andrew
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or