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

How can I can the value and data of the chosen combobox and display the information on a textbox?

3 Answers 1232 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 08 Oct 2020, 08:45 AM

@(Html.Kendo().ComboBox()
                   .Name("TransferItemId")
                   .DataTextField("Location.Code")
                   .DataValueField("Id")

                   .DataSource(source =>
                                    {
                                        source.Read(read =>
                                        {
                                            read.Action("GetInventoryPallets", "Item" });

                                        })
                                    .ServerFiltering(true);
                                    })

)

3 Answers, 1 is accepted

Sort by
0
Petar
Telerik team
answered on 12 Oct 2020, 07:42 AM

Hi Jon,

As the current ticket is submitted in the Kendo UI for Angular section of our forum, I've changed its product to UI for ASP.NET MVC. I hope that this is the suite that you are using. If you are using UI for ASP.NET Core, the approach will be the same as described below. 

To take the value of the ComboBox, you will have to use JavaScript code similar to the one in this Dojo

The below code gets the currently selected value and text of the ComboBox component. Having these values you can display them inside a TextBox. The below code uses the value and text methods of the ComboBox.

      $("#getValue").on("click", function(){
        var combobox = $("#TransferItemId").data("kendoComboBox");
        console.log("value=",combobox.value());
        console.log("text=",combobox.text());
      });

I hope the above will help you implement the targeted functionality in the application you are working on. 

Regards,
Petar
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).

0
Jon
Top achievements
Rank 1
answered on 13 Oct 2020, 12:26 AM
If I have a Javascript function, how can I call the function using the kendo combobox?
0
Petar
Telerik team
answered on 14 Oct 2020, 02:14 PM

Hi Jon,

You can check the API page of the ComboBox component.

In the events sections of the link, there are multiple events you can use to execute your custom JavaScript function. Here is a Dojo sample demonstrating how we can execute a custom function when the open event is triggered. 

For more details about how to use each of the events, you can click on their links and see the examples inside the opened pages. 

Regards,
Petar
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).

Tags
ComboBox
Asked by
Jon
Top achievements
Rank 1
Answers by
Petar
Telerik team
Jon
Top achievements
Rank 1
Share this question
or