3 Answers, 1 is accepted
0
AHMED
Top achievements
Rank 1
answered on 31 Mar 2019, 06:47 AM
Please I need your help
0
Accepted
Hello Ahmed,
Please provide more details on the exact Repeater and ComboBox configuration and provide more specific examples of what exactly should happen.
One possible option to access all ComboBoxes in the Repeater would be if you add a custom CSS class to the CssClass property of the ComboBoxes you would like to modify and when needed to use JavaScript to access all combo boxes. Then, you can iterate them, access the client-side object and use their API.
Here is a very simple example that synchronizes the selected items across all ComboBoxes in the Repeater that have the "myclass" set to the CssClass property:
Regards,
Peter Milchev
Progress Telerik
Please provide more details on the exact Repeater and ComboBox configuration and provide more specific examples of what exactly should happen.
One possible option to access all ComboBoxes in the Repeater would be if you add a custom CSS class to the CssClass property of the ComboBoxes you would like to modify and when needed to use JavaScript to access all combo boxes. Then, you can iterate them, access the client-side object and use their API.
Here is a very simple example that synchronizes the selected items across all ComboBoxes in the Repeater that have the "myclass" set to the CssClass property:
<script>
window.isProgrammaticSelection =
false
;
function
OnClientSelectedIndexChanged(sender, args) {
if
(!window.isProgrammaticSelection) {
window.isProgrammaticSelection =
true
;
var
allComboBoxes = $telerik.$(
".myclass"
);
var
value = args.get_item().get_value();
for
(
var
i = 0; i < allComboBoxes.length; i++) {
var
combo = allComboBoxes[i].control;
var
item = combo.findItemByValue(value);
item.select();
}
window.isProgrammaticSelection =
false
;
}
}
</script>
<
asp:Repeater
ID
=
"Repeater1"
OnItemDataBound
=
"Repeater1_ItemDataBound"
runat
=
"server"
>
<
ItemTemplate
>
<
telerik:RadComboBox
ID
=
"RadComboBox1"
CssClass
=
"myclass"
runat
=
"server"
RenderMode
=
"Lightweight"
OnClientSelectedIndexChanged
=
"OnClientSelectedIndexChanged"
>
<
Items
>
<
telerik:RadComboBoxItem
Text
=
"Item 1"
Value
=
"1"
/>
<
telerik:RadComboBoxItem
Text
=
"Item 2"
Value
=
"2"
/>
<
telerik:RadComboBoxItem
Text
=
"Item 3"
Value
=
"3"
/>
<
telerik:RadComboBoxItem
Text
=
"Item 4"
Value
=
"4"
/>
</
Items
>
</
telerik:RadComboBox
>
<
br
/>
</
ItemTemplate
>
</
asp:Repeater
>
protected
void
Page_Load(
object
sender, EventArgs e)
{
Repeater1.DataSource = Enumerable.Range(1, 10).Select(x =>
"Item "
+ x.ToString());
Repeater1.DataBind();
}
protected
void
Repeater1_ItemDataBound(
object
sender, RepeaterItemEventArgs e)
{
var combo = e.Item.FindControl(
"RadComboBox1"
)
as
RadComboBox;
}
Regards,
Peter Milchev
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
AHMED
Top achievements
Rank 1
answered on 01 Apr 2019, 06:13 PM
Thank you very much, you solved my problem :)