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

Programmatic cascading... .search() needs some attention

1 Answer 93 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 17 Jan 2013, 03:11 AM
Cascading works great when a person does the item selection.  The key is that the _focus method of the List widget ( I guess an ancestor of ComboBox and DropDownList ) has this kernel:

that._select(li);
that._triggerCascade();

For the case of a programmatic selection via invocation of

.select(index)
.value(data-value)
.search(data-text)

In DropDownList

.select() will perform a ._select followed by a _triggerCascade
.value() will perform a .select(index) which will eventually do a _triggerCascade
.search() will perform a ._select only and not have a _triggerCascade

In v2012.3.1304 dropdownlist.js at line 272 there should probably needs to be a
if (that._selectedIndex > -1) { that._triggerCascade() }


Now suppose that you have three remote datasourced drop down lists to be populated and initialized based on text.
The search method could then be used in the databound callback to ensure DDL has its data before making the selection of the desired item.
$.when ( $.get ('/cgi/initialValues') )
.done ( loadDDL )
;
 
// initialValues is expected to output json of construct {DDL1:text1, DDL2:text2, DDL3:text3}
 
function LoadDDL (initial) {
  $('#DDL1').kendoDropDownList ({
    dataSource: ...
    databound: function (e) {if (initial.DDL1) {var text=initial.DDL1;initial.DDL1=null;e.sender.search(text);}}
  });
  $('#DDL2').kendoDropDownList ({
    dataSource: ...
    cascadeFrom: 'DDL1'
    databound: function (e) {if (initial.DDL2) {var text=initial.DDL2;initial.DDL2=null;e.sender.search(text);}}
  });
  $('#DDL3').kendoDropDownList ({
    dataSource: ...
    cascadeFrom: 'DDL2'
    databound: function (e) {if (initial.DDL3) {var text=initial.DDL3;initial.DDL3=null;e.sender.search(text);}}
    change: doSomethingElse
  });
   
  var doSomethingElse = function() {
  // I can operate knowing the DDLs were populated and cascaded in a 1,2,3 manner
  }
}

p.s. Autogenerated cascading DDLs could be an alternate viewer for Hierarchical Data Source

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 18 Jan 2013, 12:22 PM
Hello Richard,

 
We will address this issue in next internal build of Kendo UI. For now I will suggest you use the select method instead of search method. The difference is:

  • select method - selects item and change event will not be triggered on blur
  • search method - selects first match and change event will be triggered on blur

I updated your Telerik points because of the involvement.


Regards,

Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
DropDownList
Asked by
Richard
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or