I have the following code
So the combox Box will load items in it with the 1st one diplayed and one try to click on any item the function as shown will redirect to another page.But my problem is when i click on 1st item the function is not called since the comboBox considers that the index was not changed. How can i do that without adding a dummy text and value as 1st item?
<
telerik:RadComboBox
ID
=
"RadComboBoxCat"
OnClientSelectedIndexChanged
=
"setText"
runat
=
"server"
Width
=
"138px"
EnableEmbeddedSkins
=
"false"
Font-Size
=
"8pt"
Font-Names
=
"tahoma"
ForeColor
=
"White"
skin
=
"comboSkin"
/>
<
script
type
=
"text/javascript"
language
=
"javascript"
>
function setText() {
document.getElementById("<%=btnsearch1.ClientID %>").click();
}
RadComboBoxCat.DataSource = dtCategories
RadComboBoxCat.DataTextField = "subject"
RadComboBoxCat.DataValueField = "subjectcode"
RadComboBoxCat.DataBind()
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnSearch.Click
Dim url As String
Dim str = txtSearch.Text
For j As Integer = 0 To str.Length - 1
If (str.Contains("+")) Then
str = str.Replace("+", "%2B")
End If
Next
url = hrefpath & "locate.aspx?search=" & RadComboBoxSearch.SelectedValue Response.Redirect(url)
End Sub
So the combox Box will load items in it with the 1st one diplayed and one try to click on any item the function as shown will redirect to another page.But my problem is when i click on 1st item the function is not called since the comboBox considers that the index was not changed. How can i do that without adding a dummy text and value as 1st item?
7 Answers, 1 is accepted
0
Hello maha,
Instead of the client-side SelectedIndexChanged event you can use the following code:
The code put at the place of the comment will execute every time you click on any item.
I hope this helps.
Greetings,
Simon
the Telerik team
Instead of the client-side SelectedIndexChanged event you can use the following code:
(
function
($) {
$(
".rcbItem"
).click(
function
() {
// handle item click
});
})($telerik.$);
The code put at the place of the comment will execute every time you click on any item.
I hope this helps.
Greetings,
Simon
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
maha
Top achievements
Rank 1
answered on 07 Aug 2010, 09:45 AM
How to check or get the item value selected inside that function?
0
Hello maha,
Each Item element has an expando named "_item" so you can get the reference to the Item object through it, e.g.
Regards,
Simon
the Telerik team
Each Item element has an expando named "_item" so you can get the reference to the Item object through it, e.g.
(
function
($) {
$(
".rcbItem"
).click(
function
() {
var
item =
this
._item;
});
})($telerik.$);
Regards,
Simon
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
maha
Top achievements
Rank 1
answered on 16 Aug 2010, 08:16 AM
I wanna get the item selected value.I tried item.value but didnt work.what can i use?
0
Hello maha,
You can get the value of the Item by calling item.get_value().
Here is a list with the most commonly used client-side methods and properties of the RadComboBoxItem object.
Kind regards,
Simon
the Telerik team
You can get the value of the Item by calling item.get_value().
Here is a list with the most commonly used client-side methods and properties of the RadComboBoxItem object.
Kind regards,
Simon
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
maha
Top achievements
Rank 1
answered on 17 Aug 2010, 01:10 PM
I am receiving this javascript error :
'item' is null or not an object
And another problem i have two comboBox in the page I want the function to be called for only one comboBox.
'item' is null or not an object
And another problem i have two comboBox in the page I want the function to be called for only one comboBox.
(function($) {
$(".rcbItem").click(function() {
// // handle item click
var item = this._item;
alert(item.get_value());
});
})($telerik.$);
0
Hello maha,
I just tested the code again and it worked find. Additionally you can limit the event attaching to only one RadComboBox if you use a context. Below is an example for both requirements:
I hope this helps.
All the best,
Simon
the Telerik team
I just tested the code again and it worked find. Additionally you can limit the event attaching to only one RadComboBox if you use a context. Below is an example for both requirements:
<
form
id
=
"form1"
runat
=
"server"
>
<
asp:ScriptManager
ID
=
"ScriptManager1"
runat
=
"server"
/>
<
div
>
<
telerik:RadComboBox
ID
=
"RadComboBox1"
runat
=
"server"
OnClientLoad
=
"onLoad"
>
<
Items
>
<
telerik:RadComboBoxItem
Text
=
"1"
/>
<
telerik:RadComboBoxItem
Text
=
"2"
/>
<
telerik:RadComboBoxItem
Text
=
"3"
/>
</
Items
>
</
telerik:RadComboBox
>
<
telerik:RadComboBox
ID
=
"RadComboBox2"
runat
=
"server"
>
<
Items
>
<
telerik:RadComboBoxItem
Text
=
"1"
/>
<
telerik:RadComboBoxItem
Text
=
"2"
/>
<
telerik:RadComboBoxItem
Text
=
"3"
/>
</
Items
>
</
telerik:RadComboBox
>
</
div
>
</
form
>
<
script
type
=
"text/javascript"
>
function onLoad(sender) {
$telerik.$(".rcbItem", sender.get_dropDownElement())
.click(function () {
var item = this._item;
alert(item.get_text());
});
}
</
script
>
I hope this helps.
All the best,
Simon
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