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

Additional Data callback not sending combobox reference parameter to function

1 Answer 160 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 20 Jul 2017, 10:35 PM

According to your docs:

http://docs.telerik.com/aspnet-mvc/helpers/combobox/overview#parameter-sending-to-server

There is a default event handler for the Data callback of the datasource. This event handler passes a reference to the combobox firing the event that can be resolved by running ".data("kendoComboBox")" against it.

However if I manually hookup the same function, I get an error when typing something into the combox, because the "selector" parameter isn't actually a combobox.

http://dojo.telerik.com/iPeca/3

It appears to be a bug?

I am trying to create a Data function that sends a reference to the combobox calling it as a parameter. And I cannot use strict ID selectors, because all my comboboxes have ID's that are generated dynamically at runtime.

1 Answer, 1 is accepted

Sort by
0
Veselin Tsvetanov
Telerik team
answered on 24 Jul 2017, 01:07 PM
Hi Peter,

I am afraid, that you won't be able to retrieve the reference to the ComboBox with DataSource fires the Read action within the Data function. The reason for that is the fact that the DataSource is actually independent from the CombBox and does not know which ComboBox uses it. 

As far as I can see from the ticket description, you are using the Telerik UI for ASP.NET MVC ComboBox helper. IF this is the case, you could workaround this limitation by passing a parameter (with the combo ID) to the Read action of the DataSource:
source.Read(read =>
{
    read.Action("ReadProducts", "Home", new { testParam = [your combo id] } ).Data("additionalData");
})

Then in the additionalData() function, the parameter could be retrieved from the request URL:
function additionalData() {
    var comboId = this.url.split("?testParam=")[1];
    var combo = $('#' + comboId).data('kendoComboBox');
...............

You could find further information on this topic in the following forum thread.

Regards,
Veselin Tsvetanov
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
ComboBox
Asked by
Peter
Top achievements
Rank 1
Answers by
Veselin Tsvetanov
Telerik team
Share this question
or