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

KendoUI ComboBoxFor doesn't bind on post

11 Answers 2092 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Mika
Top achievements
Rank 1
Mika asked on 05 Dec 2012, 09:42 AM
I have the following ComboBox on my view
@(Html.Kendo().ComboBoxFor(m => m.CurrentBooking.Resource.ResourceId)
    .Name(
"resourceAutoComplete")
    .DataTextField(
"ResourceName")
    .DataValueField(
"ResourceId")
    .BindTo(Model.Resources)
    .Placeholder(
"Select resource"))
But in my Save() action the Model.CurrentBooking.Resource is always null, and Model.CurrentBooking.ResourceId is always 0.

What am I doing wrong in my ComboBoxFor() configuration?

11 Answers, 1 is accepted

Sort by
0
Accepted
Georgi Krustev
Telerik team
answered on 05 Dec 2012, 09:49 AM
Hello,

 
When strongly bound HTML helper is used, a.k.a ComboBoxFor<T>, do not set the Name manually. I will suggest you remove the Name method of the declaration of the widget.

Regards,
Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Mika
Top achievements
Rank 1
answered on 05 Dec 2012, 09:53 AM
Thank you, removing the Name -method fixed the issue :)
0
Douglas
Top achievements
Rank 1
answered on 26 Dec 2013, 05:03 PM
This fixed my problem but why is it causing the problem? Is this a bug?
0
Atanas Korchev
Telerik team
answered on 27 Dec 2013, 09:10 AM
Hello Douglas,

No, this is not a bug. This is the way ASP.NET MVC model binding works. It expects the name of the input to match the property name of the model. If there is no such match then it won't work.

More info can be found in this blog post.

Regards,
Atanas Korchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Gerber
Top achievements
Rank 1
answered on 06 Jun 2014, 08:00 AM
Hi - going back on this one... if I remove the Name.. how will Cascading works? In my case, cascading no longer works.
Thanks,
Gerber
0
Atanas Korchev
Telerik team
answered on 10 Jun 2014, 08:09 AM
Hello Gerber,

In order for cascading to work you need to specify the actual ID of the parent combobox - the one that ASP.NET MVC has generated for it. You can either inspect the generated HTML output to get the actual ID or override the ID of the combobox via the HtmlAttributes method:

@(Html.Kendo().ComboBoxFor().HtmlAttributes(new { id = "myid" })

@(Html.Kendo().ComboBoxFor().CascadeFrom("myid"))

Regards,
Atanas Korchev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
ajith
Top achievements
Rank 1
answered on 20 May 2015, 10:40 AM

Hi, Atanas

    When i try to cascade comboboxfor, it wil hides other comboboxes. 

@(Html.Kendo().ComboBoxFor(m => m.SubgroupCode)
 
             .HtmlAttributes(new { style = "width:160px", id = "Subgroupid" })
             .Placeholder("Select product...")
             .DataTextField("Name")
             .DataValueField("ID")
             .Filter(FilterType.Contains)
             .DataSource(source =>
             {
                 source.Read(read =>
                 {
                     read.Action("GetAssetSubgroup", "Asset").Data("filterSubGroups");
 
                 })
                 .ServerFiltering(true);
             })
             .Enable(false)
             .AutoBind(false)
             .CascadeFrom("groupid")
       )
                   <script>
                       function filterSubGroups() {
                           return {
                               groups: $("#groupid").val(),
                               groupfilter: $("#Subgroupid").data("kendoComboBox").input.val()
                           };
                       }
                   </script>
               </td>

 

 

please help me

0
micky
Top achievements
Rank 1
answered on 30 Mar 2020, 01:02 PM

Thanks Man

Regards

0
Petar
Telerik team
answered on 01 Apr 2020, 09:58 AM

Hi Micky,

Do you need any assistance with this thread? 

Regards,
Petar
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
kevin
Top achievements
Rank 1
answered on 18 Jun 2020, 12:14 PM

I would like to pickup on this thread. I have added the id 
@(Html.Kendo().ComboBoxFor(m=>m.MyProp)
.HtmlAttributes(new { style = "width:100%;", id = "myId" })

But my other control is still not firing on change.

.CascadeFrom("myId")

 

What am I missing?

0
Martin
Telerik team
answered on 22 Jun 2020, 10:16 AM

Hello Kevin,

Attached you will find a small project with Cascading Comboboxes, with an id HtmlAttribute added to the parent component. Could you please review it and see if it will help you resolve the problem? Feel free to modify the example to show any issues you are experiencing on the matter.

Looking forward to your reply.

Regards,
Martin
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
ComboBox
Asked by
Mika
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Mika
Top achievements
Rank 1
Douglas
Top achievements
Rank 1
Atanas Korchev
Telerik team
Gerber
Top achievements
Rank 1
ajith
Top achievements
Rank 1
micky
Top achievements
Rank 1
Petar
Telerik team
kevin
Top achievements
Rank 1
Martin
Telerik team
Share this question
or