Cascading in Kendo MVC

2 posts, 0 answers
  1. Mohammed Adel
    Mohammed Adel avatar
    2 posts
    Member since:
    Mar 2012

    Posted 24 Jun 2012 Link to this post

    How can we make a cascading dropdownlist or combobox like the country and cities in kendo.
    Thanks in Advance
  2. Samuel
    Samuel avatar
    19 posts
    Member since:
    Aug 2012

    Posted 21 Aug 2012 Link to this post

    I have a ticket in with Kendo about the documentation (or lack thereof) specifically on DropDownList and DropDownListFor. I've been knocking my head against this brick wall for most of today and finally got a (very simple) case together. Looking at it, I'm not sure I like where it's going and I'd prefer a Parent attribute for the child. In any case, I hope this example helps somewhat (this is a snippet from my View - it's self-contained so you don't need to know anything about even the model) and if anybody wants to expand on it... go ahead. In order to help with the readability, I haven't done anything with BindTo or DataSource other than a commented out line. You could easily .BindTo a SelectList with the appropriate elements.
    @(Html.Kendo().DropDownList()
    .Name("CountryID")
    .Items(items =>
        {
            items.Add().Text("United States").Value("1");
            items.Add().Text("Mexico").Value("2");
            items.Add().Text("Germany").Value("3");
        })
        .DataTextField("Text")
        .DataValueField("Value")
        //.BindTo(myCountries)
    .OptionLabel("Select Country")
    )
     
    @(Html.Kendo().DropDownList()
    .Name("CityID")
    .Items(items =>
        {
            items.Add().Text("Chicago").Value("1");
            items.Add().Text("Puerto Vallarta").Value("2");
            items.Add().Text("Berlin").Value("3");
            items.Add().Text("San Francisco").Value("1");
            items.Add().Text("Frankfurt").Value("3");
            items.Add().Text("Mexico City").Value("2");
        })
        .DataValueField("Value")
        .DataTextField("Text")
        .CascadeFrom("CountryID")
        .OptionLabel("Select City")
        //.BindTo(myCities)
    )
  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top