Binding to Model, then cascade

7 posts, 0 answers
  1. Gabor
    Gabor avatar
    1 posts
    Member since:
    Jul 2012

    Posted 10 Dec 2012 Link to this post

    Hi, 

    I have a scenario, where I have two drop-downs that I want to cascade. This is working to an extent, but when I want to expand the functionality to bind intially to a model list, then select a value on page load, I can't think of a way to make this happen. 

    These are the two drop-downs: 

    Html.Kendo().DropDownListFor(c => c.SelectedGroup)              
                      .BindTo(Model.Groups)
                      .Value(Model.SelectedGroup.Value.ToString())
                      .HtmlAttributes(new { style = "width: 250px" })
                      .Render();
    And 

    @(Html.Kendo().DropDownListFor(t => t.AuthorisedByExtraID)
                            .DataTextField("Name")
                            .DataValueField("ExtraUserID")
                            .DataSource(source =>
                                source.Read(read => read.Action("SearchAutocompleteEmployees", "Search")
                                                            .Data("onAutoCompleteAdditional")
                                                            .Type(HttpVerbs.Post))
                                        .ServerFiltering(true))
                                  .HtmlAttributes(new { style = "width: 250px" })
                                  .Enable(false)
                                  .AutoBind(true)
                                  .BindTo(Model.GroupEmployees)
                                  .Value(Model.AuthorisedByExtraID.HasValue ? Model.AuthorisedByExtraID.Value.ToString() : "0")
                          .CascadeFrom("SelectedGroup")
        )
    How can I enable the second drop-down to bind to Model.AuthorisedByExtraID when it exists, then when group changes, 
    to load the contents via ajax? 
    
    Thanks,
    Gabor
  2. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 10 Dec 2012 Link to this post

    Hello Gabor,

     
    Here is a quote of my answer to the support ticket opened on the same subject:

    Thank you for contacting us. We improved cascading functionality of the DropDownLists/ComboBox widget after the official release of Kendo UI. I will suggest you download the latest internal build and give it a try. Also you will need to set the autoBind option of the second DropDownList to false. Thus the parent will be able to set it correctly after it filters the data of the child widget. Let me know what your findings are.

    I will suggest you continue our discussion in only one thread to avoid any duplications.

    Kind 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!
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Andrii
    Andrii avatar
    13 posts
    Member since:
    Nov 2011

    Posted 16 May 2013 Link to this post

    I have two dropdowns, and want to bind it to model and make them as cascade.

    @(Html.Kendo().ComboBoxFor(model => model.CountryId)
                    .Name("Countries")
                    .DataTextField("Text")
                    .DataValueField("Value")
                    .Filter(FilterType.Contains)
                    .BindTo(ViewBag.Countries)
                    .HtmlAttributes(new { @class = "input-block-level" })
            )
    @(Html.Kendo().ComboBoxFor(model => model.CityId)               
                    .Filter(FilterType.Contains)
                    .DataSource(source =>
                    {
                        source.Read(read =>
                        {
                            read.Action("GetCitiesByCountry", "Employee");
                        }).ServerFiltering(true);
                    })
                    .DataTextField("Text")
                    .DataValueField("Value")
                    .AutoBind(false)
                    .CascadeFrom("Countries")
            .HtmlAttributes(new { @class = "input-block-level" }))
    To make cascade, i must give them names, but wth names they don't bind data.
    How to make cascade and to bind selected data with model?
  5. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 20 May 2013 Link to this post

    Hello Andriy,

     
    I will suggest you check this help topic regarding strongly-typed Html extensions. In order to get correct name for the cascading functionality you can use GetFullHtmlFieldName method.

    Kind 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!
  6. Andrii
    Andrii avatar
    13 posts
    Member since:
    Nov 2011

    Posted 20 May 2013 Link to this post

    Thanks for help!
    But it doesn't help. With any other name cascade works, but with this like "HomeAddress.CountryId" got by GetFullHtmlFieldName("") cascade doesn't work
  7. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 21 May 2013 Link to this post

    Hello Andriy,

     
    The "." is not valid jQuery ID selector. You will need to escape all points in the name. Thus jQuery will be able to find the parent element correctly -> "HomeAddress\\.CountryId".

    All the best,
    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!
  8. Andrii
    Andrii avatar
    13 posts
    Member since:
    Nov 2011

    Posted 21 May 2013 Link to this post

    It started to work only when i'm changed "." to "_" and "[" "]" to "\\[" "\\]"
    EmergencyContacts\\[0\\]_Address_CountryId - its my selector that really works (2013.1.514).
    Thanks for help!
Back to Top
UI for ASP.NET MVC is VS 2017 Ready