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

[Solved] Unable to get selected item on CascadeTo

2 Answers 81 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Michael Evans
Top achievements
Rank 1
Michael Evans asked on 29 Jun 2012, 07:13 PM
I'm trying to add a set of cascading combo boxes to my MVC4 application.  However, the problem I'm having is that the controller is not receiving the selected item from the first combo box.  The method is being called, but the parameter is null.  This is what the view looks like:

<p>
        <label for="ComboBox_Flights-input">Flights</label>
         
        @(Html.Telerik().ComboBoxFor(x => x.SelectedFlightDataId)
            .Name("ComboBox_Flights")
            .BindTo(new SelectList(Model.ValidFlights, "FlightDataId", "LineAndNumber"))
            .CascadeTo("ComboBox_BoardingSequences")
            )
 
</p>
<p>
        <label for="ComboBox_BoardingSequences-input">Boarding Sequences</label>
        @(Html.Telerik().ComboBoxFor(x => x.SelectedTemplateId)
                .Name("ComboBox_BoardingSequences")
                .DataBinding(binding => binding.Ajax().Select("_GetValidBoardingSequencesForFlight", "BoardingSequence"))     
        )
</p>

And here is the code in the controller:

        [HttpPost]
        public JsonResult _GetValidBoardingSequencesForFlight(int? FlightDataId)
        {
// ... snip ...
        }

FlightDataId is my parameter and it comes back null after I select an item from the first combo.  I have looked at your examples and I don't see what I am doing wrong.  Any help would be appreciated.

2 Answers, 1 is accepted

Sort by
0
Accepted
Georgi Krustev
Telerik team
answered on 03 Jul 2012, 07:39 AM
Hello Michael,

 
The key-value pair, which second combobox will send to the server, will be the name of the first combobox "ComboBox_Flights" and its value. Hence the _GetValidBoardingSequencesForFlight method should wait for "ComboBox_Flights", and not for "FlightDataId".

Regards,
Georgi Krustev
the Telerik team
Check out the successor of Telerik MVC Extensions - Kendo UI for ASP.NET MVC - and deem it for new ASP.NET MVC development.
0
Michael Evans
Top achievements
Rank 1
answered on 03 Jul 2012, 12:58 PM
Thanks, Georgi.  Apparently I'm blind because now that I look at the example I can see that is what is done there.  I was looking at the bottom private method which had the parameter name ending with ID.  This worked perfectly.
Tags
ComboBox
Asked by
Michael Evans
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Michael Evans
Top achievements
Rank 1
Share this question
or