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

[Solved] Clientside select and OnChange Event

5 Answers 152 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
JULIA
Top achievements
Rank 1
JULIA asked on 01 Sep 2010, 12:51 PM
Hello,

the clientside selectmethod doesn't trigger the OnChange event. Is there way to trigger this event manually.

Regards,
Timo

5 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 01 Sep 2010, 01:30 PM
Hello Timo,

This is by design. Otherwise calling select method from the onchange handler would lead to recursion.

Why do you need to trigger the change event? Can't you just call the onchange handler manually after calling select?

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
JULIA
Top achievements
Rank 1
answered on 01 Sep 2010, 01:59 PM
Hello,

i have four related comboboxes. if there is only one item returned from server for a combobox, this item should be selected and the onchange event should be triggered to fill the next combobox.

Samplecode:
function atcChanged(e) {
    var sList = $('#Agent_SelectedSupplier').data('tDropDownList');
    var agentTextBox = $('#Agent_AutoCompleteAgent').data('tAutoComplete');
    getData('<%= Url.Content("~/...") %>', { atcCode: e.value, agent: agentTextBox.text() }, sList);
}
  
function supplierChanged(e) {
    var atcList = $('#Agent_SelectedAtcCode').data('tDropDownList');
    var pList = $("#Agent_DropDownProduct").data('tDropDownList');
    getData('<%= Url.Content("~/...") %>', { supplier: e.value, atcCode: atcList.value() }, pList);
}
  
function getData(url, params, cbx) {
    $.getJSON(url, params, function (data) {
        if (data.Data) {
            cbx.dataBind(data.Data);
  
            if (data.Data.length == 1) {
                cbx.select(0); // trigger onChange
            }
            else {
                ctrl.text(" ");
                ctrl.open();
            }
        }
    });
}
0
Atanas Korchev
Telerik team
answered on 01 Sep 2010, 03:19 PM
Hello Timo,

If you just want to trigger the ajax loading you can try the reload() JavaScript method of the combobox.

Sincerely yours,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
JULIA
Top achievements
Rank 1
answered on 02 Sep 2010, 08:09 AM
Hello,

reload doesn't run the code in onChange. in this event the comboboxes will be filled with jquery. if there is only one item returned from server this item is selected and the onChange event should be running.

Regards,
Timo
0
Atanas Korchev
Telerik team
answered on 02 Sep 2010, 08:16 AM
Hello Timo,

Since the select method does not invoke the onchange event I suggest you call the onchange handler manually. I am afraid there is nothing else to do right now.

All the best,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
ComboBox
Asked by
JULIA
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
JULIA
Top achievements
Rank 1
Share this question
or