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

using Jquery Selector

5 Answers 85 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Divyang
Top achievements
Rank 1
Divyang asked on 21 Jul 2011, 08:16 AM
Hi,

How can we find all RadCombobox using jQuery Seletor and also attach javascript function to it.

Actual requirement is to find all controls on the page by jquery selector or telerik client api if available.

5 Answers, 1 is accepted

Sort by
0
Kalina
Telerik team
answered on 21 Jul 2011, 05:17 PM
Hello Divyang,

You can get all RadComboBox controls on a page via the control client-side API:
var combos = Telerik.Web.UI.RadComboBox.ComboBoxes;

All the best,
Kalina
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Will
Top achievements
Rank 1
answered on 15 Sep 2013, 11:40 AM
Hi,

If I have a page containing 10 combo controls and 5 of them are within a div. How can I access only the 5 within a div rather than all 10 of them.

var combos = Telerik.Web.UI.RadComboBox.ComboBoxes will give me all of them.

Thanks,


0
moegal
Top achievements
Rank 1
answered on 15 Sep 2013, 08:39 PM
if your JavaScript is on the same page then you can find the id like this:
var combo = $find("<%= RadComboBox1.ClientID %>");

If your JavaScript is not on the aspx page, I sometimes will assign a unique class to the field like CssClass="idRadComboBox1"

The I can reference it like this:  var combo= $find($('.idRadComboBox1').attr('id'));

Marty

0
Will
Top achievements
Rank 1
answered on 16 Sep 2013, 12:25 PM
Hi Marty,

Rather than accessing the combo boxes one at a time, is there a way I can access of 5 of them at once. If I was to use a normal asp.net dropdownlist I would use something like

var combos = document.getElementById("IdOfDiv").getElementByTagName("select");

but unfortunately when telerik's radcombo list renders the html, there is no select tag.

Thanks,
0
moegal
Top achievements
Rank 1
answered on 16 Sep 2013, 07:54 PM
I guess you could assign a group CssClass and then with jquery you will get an array that you can loop thru.

like:

<div>
            <telerik:RadComboBox ID="RadComboBox1" runat="server" DataSourceID="SqlDataSource1"
                DataTextField="stateName" DataValueField="stateID" CssClass="RadComboBoxes idRadComboBox1"
                EmptyMessage="Select State">
            </telerik:RadComboBox>
        </div>
        <div>
            <telerik:RadComboBox ID="RadComboBox2" runat="server" DataSourceID="SqlDataSource1"
                DataTextField="stateName" DataValueField="stateID" CssClass="RadComboBoxes idRadComboBox2"
                EmptyMessage="Select State">
            </telerik:RadComboBox>
        </div>

then If i were to use the jquery selector: console.log($('.RadComboBoxes'))

I would see something like:
[div#RadComboBox1.RadComboBox RadComboBox_Telerik RadComboBoxs idRadComboBox1, div#RadComboBox2.RadComboBox RadComboBox_Telerik RadComboBoxs idRadComboBox1, prevObject: b.fn.b.init[1], context: document, selector: ".RadComboBoxs", jquery: "1.9.1", constructor:function…]

You could loop thru this mess and find your individual client ids for each combo. 

Marty



Tags
General Discussions
Asked by
Divyang
Top achievements
Rank 1
Answers by
Kalina
Telerik team
Will
Top achievements
Rank 1
moegal
Top achievements
Rank 1
Share this question
or