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

[Solved] Setting the selected index with client API

2 Answers 169 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.
jonathan
Top achievements
Rank 1
jonathan asked on 11 Nov 2010, 01:25 AM
How do I set the selected index for a dropdownlist with the client API?
I am getting JSON data via custom AJAX call.  I set databind to populate the list.
How do I set the selected value when databinding on the client side?

Thanks
-Jonathan

2 Answers, 1 is accepted

Sort by
0
Darrien
Top achievements
Rank 1
answered on 05 Jan 2011, 08:58 PM
Any luck with this?  I'm having same issue.
0
jonathan
Top achievements
Rank 1
answered on 05 Jan 2011, 09:18 PM
The only way I have found to do this is via a inline function. This code shows matching by the text versus the value.  You can  use simple jquery selection instead of the $(e.form) syntax that I am showing for use in a grid.  dataItem and e.dataItem both support    .Text or .Value.

 $(e.form).find('#ContactTypeList').data('tDropDownList').select(function (dataItem) {
if (e.dataItem)
     return dataItem.Text == e.dataItem['ContactType'];
 else
     return false;
 });
Tags
ComboBox
Asked by
jonathan
Top achievements
Rank 1
Answers by
Darrien
Top achievements
Rank 1
jonathan
Top achievements
Rank 1
Share this question
or