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

GridImageColumn On Image Click

1 Answer 302 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 2
Allan asked on 10 Jun 2010, 04:19 PM
I have a radgrid with a GridImageColumn. I display a thumbnail image in the image column form a data base.  I have set the Grid's onrowdblclick to instantiate some java to popup a radwindow with a larger version of the image.

Everything works great... EXCEPT, if the user double clicks the actual thumbnail image. Nothing happens. Is there a way to either make the GridImageColumn or the thumbnail image also call the java script like the onrowdblclick event?


                        <script type="text/javascript">  
                            function RowClick(sender, eventArgs) {  
                                var MasterTableView = eventArgs.get_tableView();  
                                var cell = MasterTableView.getCellByColumnUniqueName(MasterTableView.get_dataItems()[eventArgs.get_itemIndexHierarchical()], "IDImages");  
                                var oWnd = radopen("../../imagemanager/imagedisplay.aspx?IDImages=" + cell.innerHTML);  
                    <telerik:RadGrid ID="rg_VehicleImages" runat="server"   
                        AllowAutomaticDeletes="True" AutoGenerateDeleteColumn="True" CssClass="radgrid"   
                        DataSourceID="sds_ImagesVehicle" GridLines="None" Width="220px">  
                        <mastertableview autogeneratecolumns="False" datakeynames="IDImages"   
                                <HeaderStyle Width="20px" /> 
                                <HeaderStyle Width="20px" /> 
                                <telerik:GridBoundColumn DataField="IDimages" DefaultInsertValue=""   
                                    HeaderText="" ItemStyle-ForeColor="White" ItemStyle-Width="2px"   
                                    <HeaderStyle Width="2px" /> 
                                <telerik:GridImageColumn AlternateText="Thumbnail"   
                                    DataImageUrlFields="FilePath, ThumbnailName" DataImageUrlFormatString="{0}/{1}"   
                                    DataType="System.String" FooterText="ImageColumn footer" HeaderText=""   
                                    <HeaderStyle Width="75px" /> 
                                <telerik:GridBoundColumn DataField="ThumbnailName" DefaultInsertValue=""   
                                    HeaderText="ThumbnailName" SortExpression="ThumbnailName"   
                                    UniqueName="ThumbnailName" Visible="False">  
                            <clientevents onrowdblclick="RowClick"/>  


1 Answer, 1 is accepted

Sort by
Telerik team
answered on 15 Jun 2010, 11:38 AM
Hi Allan,

What you can do is give a UniqueName to the GridImageColumn, wire the ItemCreated event of the Radgrid and attach the ondblclick client event to each image in the grid. See the code snippet below.
(Let's assume you named your GridImageColumn "Image"):

protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
        if (e.Item is GridDataItem)
            GridDataItem item = (GridDataItem)e.Item;
            TableCell cell = item["Image"];
            Image img = cell.Controls[0] as Image;
            img.Attributes["ondblclick"] = "onDoubleClick(this, event);";

Kind regards,
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.
Asked by
Top achievements
Rank 2
Answers by
Telerik team
Share this question