Combo Select value after loading

4 posts, 0 answers
  1. Sentil
    Sentil avatar
    23 posts
    Member since:
    Jul 2011

    Posted 08 May 2013 Link to this post

    Hi

    I saw the below link

    http://demos.kendoui.com/web/combobox/cascadingcombobox.html

    i have three combo box

    @(Html.Kendo().ComboBox()
    .Name("userComboBox") //The name of the combobox is mandatory. It specifies the "id" attribute of the widget.
    .DataTextField("UserName") //Specifies which property of the Product to be used by the combobox as a text.
    .DataValueField("UserID") //Specifies which property of the Product to be used by the combobox as a value.
    .Filter(FilterType.StartsWith)
    .Placeholder("Select Name...")
    .DataSource(source =>
    {
    source.Read(read =>
    {
    read.Action("GetUsers", "UserDetails").Data("onAdditionalData"); //Set the Action and Controller name
    })
    .ServerFiltering(true); //If true the DataSource will not filter the data on the client.

    }).Events(e=>e.Change("combobox_change"))




    //Select first item.
    )

    @(Html.Kendo().ComboBox().Name("entityDetails")
    .DataTextField("EntityName")
    .DataValueField("EntityID")
    .DataSource(source => {
    source.Read(read =>
    {
    read.Action("GetEntity", "UserDetails").Data("onAdditionalDataEntity");
    })

    .ServerFiltering(true);
    }) .SelectedIndex(0)
    .CascadeFrom("userComboBox")



    )

    @(Html.Kendo().ComboBox().Name("ClientDetails")
    .DataTextField("ClientName")
    .DataValueField("ClientID")
    .DataSource(source => {
    source.Read(read =>
    {
    read.Action("GetClientDetails", "UserDetails").Data("onAdditionalDataForClient");
    })
    .ServerFiltering(true);
    })
    .SelectedIndex(0)
    .CascadeFrom("userComboBox")
    )

    //js
    function onAdditionalData() {
    var data = $("#userComboBox").data("kendoComboBox")
    value1 = data.input.val();
    return {
    text: value1

    };

    }
    function onAdditionalDataEntity() {
    var data = $("#userComboBox").data("kendoComboBox")
    value1 = $("#userComboBox").val();
    return {
    userData: value1,
    entity: $("#entityDetails").data("kendoComboBox").input.val()

    };

    }
    function onAdditionalDataForClient() {
    var data = $("#userComboBox").data("kendoComboBox")
    value1 = $("#userComboBox").val();
    return {
    userData: value1,
    entity: $("#ClientDetails").data("kendoComboBox").input.val()
    };

    }

    //controller
    public JsonResult GetUsers(string text)
    {
    return Json(GetActiveUser, JsonRequestBehavior.AllowGet);
    }

    public JsonResult GetClientDetails(string userData, string entity)
    {
     
    // return userDetailsDAO.GetUserDetails(id);
    return Json(GetClientDetails, JsonRequestBehavior.AllowGet);
    }
    public JsonResult GetEntity(string userData, string entity)
    {
     
    return Json(GetEntityDetails, JsonRequestBehavior.AllowGet);
    }





    1) user combo box need to cascade with other two so when i load user combo i need to load and select details
    2) i can do load but cant select the first item

    Can you guys help me

    Senthil
  2. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2172 posts

    Posted 10 May 2013 Link to this post

    Hi Sentil,

     
    From the provided information it's not clear for us what is the exact behavior that you are experiencing - could you please record a screencast to demonstrate us the issue?

    Also I would suggest to set the child DropDownLists AutoBind option to false.
     

    Kind Regards,
    Vladimir Iliev
    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. Sentil
    Sentil avatar
    23 posts
    Member since:
    Jul 2011

    Posted 10 May 2013 Link to this post

    Hi thanks

    I took this link as example http://demos.kendoui.com/web/combobox/cascadingcombobox.html

    I will explain in detail
    Issue 1:
    I have three combo box

    @(Html.Kendo().ComboBox()
    .Name("userComboBox") //The name of the combobox is mandatory. It specifies the "id" attribute of the widget.
    .DataTextField("UserName") //Specifies which property of the Product to be used by the combobox as a text.
    .DataValueField("UserID") //Specifies which property of the Product to be used by the combobox as a value.
    .Filter(FilterType.StartsWith)
    .Placeholder("Select Name...")
    .DataSource(source =>
    {
    source.Read(read =>
    {
    read.Action("GetUsers", "UserDetails").Data("onAdditionalData"); //Set the Action and Controller name
    })
    .ServerFiltering(true); //If true the DataSource will not filter the data on the client.

    }).Events(e=>e.Change("combobox_change"))




    //Select first item.
    )

    @(Html.Kendo().ComboBox().Name("entityDetails")
    .DataTextField("EntityName")
    .DataValueField("EntityID")
    .DataSource(source => {
    source.Read(read =>
    {
    read.Action("GetEntity", "UserDetails").Data("onAdditionalDataEntity");
    })

    .ServerFiltering(true);
    }) .SelectedIndex(0)
    .CascadeFrom("userComboBox")



    )

    @(Html.Kendo().ComboBox().Name("ClientDetails")
    .DataTextField("ClientName")
    .DataValueField("ClientID")
    .DataSource(source => {
    source.Read(read =>
    {
    read.Action("GetClientDetails", "UserDetails").Data("onAdditionalDataForClient");
    })
    .ServerFiltering(true);
    })
    .SelectedIndex(0)
    .CascadeFrom("userComboBox")
    )

    //js

    function onAdditionalData() {
    var data = $("#userComboBox").data("kendoComboBox")
    value1 = data.input.val();
    return {
    text: value1

    };

    }
    function onAdditionalDataEntity() {
    var data = $("#userComboBox").data("kendoComboBox")
    value1 = $("#userComboBox").val();
    return {
    userData: value1,
    entity: $("#entityDetails").data("kendoComboBox").input.val()

    };

    }
    function onAdditionalDataForClient() {
    var data = $("#userComboBox").data("kendoComboBox")
    value1 = $("#userComboBox").val();
    return {
    userData: value1,
    entity: $("#ClientDetails").data("kendoComboBox").input.val()
    };

    }

    //controller
    public JsonResult GetUsers(string text)
    {
    return Json(GetActiveUser, JsonRequestBehavior.AllowGet);
    }

    public JsonResult GetClientDetails(string userData, string entity)
    {

    // return userDetailsDAO.GetUserDetails(id);
    return Json(GetClientDetails, JsonRequestBehavior.AllowGet);
    }
    public JsonResult GetEntity(string userData, string entity)
    {

    return Json(GetEntityDetails, JsonRequestBehavior.AllowGet);
    }


    you see when i load first combo box second combobox loaded - thats how in the sample, it works it is working  for me also
    but i need to select the first item in the second combo box when loaded

    what mistake i did in my coading , Senthil
  5. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2172 posts

    Posted 14 May 2013 Link to this post

    Hi Sentil,


    I tried to reproduce the problem locally but to no avail – everything is working as expected on our side. Could you please provide runable project where the issue is reproduced? This would help us pinpoint the exact reason for this behavior.

    Kind Regards,
    Vladimir Iliev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top
UI for ASP.NET MVC is VS 2017 Ready