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

Combo Select value after loading

3 Answers 381 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Sentil
Top achievements
Rank 1
Sentil asked on 08 May 2013, 09:34 AM
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

3 Answers, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 10 May 2013, 07:02 AM
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!
0
Sentil
Top achievements
Rank 1
answered on 10 May 2013, 10:19 AM
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
0
Vladimir Iliev
Telerik team
answered on 14 May 2013, 08:36 AM
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!
Tags
ComboBox
Asked by
Sentil
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Sentil
Top achievements
Rank 1
Share this question
or