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

RadGrid : Access CommandItem Control in Javascript

1 Answer 82 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jimmy Vithalani
Top achievements
Rank 1
Jimmy Vithalani asked on 20 Jul 2010, 08:52 AM
<RSCtl:RSGrid ID="RSGrid1" IsConfigDrivenGrid="true" runat="server" style="margin:5" >
   <MasterTableView CommandItemDisplay="Top">
 
      <CommandItemTemplate>
          <table id="tblGridCommandItem" runat="server" cellpadding="0" cellspacing="0" width="100%">
              <tr width="100%">
                  <td align="right">
                                                                                                    <asp:Label ID="lblSearchResultTime" runat="server" CssClass="RSGrid_HeaderCommandItem_Message" />
                                                                                                     
              </td>
           </tr>
        </table>
                                                                                    </CommandItemTemplate>
</MasterTableView>
</RSCtl:RSGrid>


Above is my code for grid. I want to access label which is in the CommandItemTemplate in javascript. I am in OnResponseEnd event of RadAjaxManager. 

Thanks.
Jimmy.

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 20 Jul 2010, 10:57 AM
Hello,


A comfy method to access the Label from client side is, accessing the Label from code behind and saving the ClientID in a global location where we can access from client also; like HiddenField. Now in the client method, access the HiddenField to get the ClientID of Label, and then get reference to Label client object.

Here is an example for the code to access Label from code behind.
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    if (e.Item is GridCommandItem)
    {
        GridCommandItem commandItem = (GridCommandItem)e.Item;
        Label lbl = Label) commandItem.FindControl("lblSearchResultTime");
        HiddenField1.Value = lbl.ClientID;
    }
}


-Shinu.
Tags
Grid
Asked by
Jimmy Vithalani
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or