How to get client-side reference to telerik control in Command Template of a RadGrid

0 Answers 27 Views
Grid
ToltingColtAcres
Top achievements
Rank 2
Veteran
Iron
ToltingColtAcres asked on 27 Feb 2024, 04:12 PM

I need to get a reference to a telerik control contained in the commanditemtemplate of a radgrid using javascript.

Given the following:


<CommandItemTemplate>
<asp:Table>
<asp:TableRow>
<asp:TableCell>
<telerik:RadComboBox runat=server ID="RadComboBox_CommandItem">


How would I get the reference to the ComboBox?

 

I've tried window.$find, $telerik.findControl and $telerik.findElement, but I keep getting a " CS0103: The name 'RadComboBox_CommandItem' does not exist in the current context"

Vasko
Telerik team
commented on 01 Mar 2024, 01:46 PM

Hello Michael,

You can obtain a reference to the controls inside the CommandItemTemplate by using the $get() command to find the Grid and then use the $telerik.findControl() method:

<script>
    function pageLoadHandler() {       
        var grid = $get("<%= RadGrid1.ClientID %>"); 
        var combo = $telerik.findControl(grid, "RadComboBox_CommandItem"); // Pass the ID of the control you want to find, which is inside the Grid
        var comboElement = combo.get_element(); // Get the html element of the control
    }
    Sys.Application.add_load(pageLoadHandler);  
</script>

I hope this helps you out.

Kind regards,
Vasko
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources

No answers yet. Maybe you can help?

Tags
Grid
Asked by
ToltingColtAcres
Top achievements
Rank 2
Veteran
Iron
Share this question
or