Click on GridImageColumn does NOT fire RowClick() event

2 posts, 0 answers
  1. Randall
    Randall avatar
    54 posts
    Member since:
    Jun 2008

    Posted 12 Sep 2011 Link to this post

    Hello,

    Using RadControls for ASP.NET v2011.2.712.35

    I have a RadGrid with client-side row click event defined as follows:

    <telerik:RadGrid runat="server" ID="RadGrid_Combo" ... >
        <ClientSettings EnableRowHoverStyle="true">
            <ClientEvents
                OnGridCreated="OP_RadGrid_GridCreated"
                OnRowSelected="OP_RadGrid_RowSelected"
                OnRowDeselected="OP_RadGrid_RowDeselected"
                />
        <MasterTableView TableLayout="Fixed">
            <Columns>
                <telerik:GridImageColumn UniqueName="ImageUrl"
                    DataAlternateTextField="ObjectType"
                    DataAlternateTextFormatString="{0} Object"
                    DataImageUrlFields="ImageUrl"
                    DataType="System.String"
                    HeaderText="Type"
                    ImageAlign="Middle"
                    ImageHeight="16px"
                    ImageWidth="16px"
                    >
                    <HeaderStyle Width="25px" Wrap="false" />
                </telerik:GridImageColumn>
    ...
    </telerik:RadGrid>

    My Javascript is:

    <script type="text/javascript">
    function OP_RadGrid_RowSelected(sender, args)
    {
        // do some stuff
        ...
    }
    </script>

    When I click on a row in the RadGrid, the OP_RadGrid_RowSelected() event fires just fine.

    However, when I click on the image in the GridImateColumn, the OP_RadGrid_RowSelected() event DOES NOT fire.

    How can I make the OP_RadGrid_RowSelected() fire when I click on the Image?

    Thanks,
    Randall Price
    Senior Developer
    Virginia Tech
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 13 Sep 2011 Link to this post

    Hello Randall,

    Give a try with the following code snippet to select the row when clicking on Image in grid row.

    C#:
    protected void RadGrid_Combo(object sender, GridItemEventArgs e)
      {
          
          if (e.Item is GridDataItem)
          {
              GridDataItem Item = (GridDataItem)e.Item;
              Image btn = (Image)Item["ImageUrl"].Controls[0];
              btn.Attributes.Add("OnClick", "imgclick('"+Item.ItemIndex+"');");
          }
      }

    Java Script:
    <script type="text/javascript">
        function imgclick(index) {
                var masterTable = $find("<%=RadGridDocuments.ClientID%>").get_masterTableView();
                 masterTable.fireCommand("Select", index); //will select the row
        }
        function RowSelected(sender, eventargs) {
        }
    </script>

    -Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top