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

Is it possible to use GridBinaryImageColumn as a hyperlink?

3 Answers 83 Views
Grid
This is a migrated thread and some comments may be shown as answers.
tomekm
Top achievements
Rank 1
tomekm asked on 02 Jun 2010, 07:00 PM

I want to have GridBinaryImageColumn that presents image from database. Can this image be inside hyperlink like

<a href="http://.../Product.aspx?Id=1"><img /></a> ?

Or any other approach that make image clickable and links to that row details?

3 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 08 Jun 2010, 07:38 AM
Hi Rychu,

Although this functionality is not available, you can assign an onclick client side handler for the image, after accessing the relevant cell, which hosts the image:

http://www.telerik.com/help/aspnet-ajax/grdaccessingcellsandrows.html

I hope this gets you started properly.

Greetings,
Yavor
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.
0
Paul Desormeaux
Top achievements
Rank 1
answered on 28 Sep 2010, 09:12 PM
This seems to work when clicking anywhere on the RadGrid row -except when clicking directly on the image itself.
In that case, nothing happens (i.e. no client-side event is fired).
Any idea why that is and how I can make clicking on the image also fire the (same) event?

Thx!

PS - sure would be nice if GridBinaryImageColumn had a hyperlink setting.

Paul

<script type="text/javascript">
 function RowSelected(sender, eventArgs)
 {
   var grid = sender;
   var MasterTable = grid.get_masterTableView();
   var row = MasterTable.get_dataItems()[eventArgs.get_itemIndexHierarchical()];
   var cell = MasterTable.getCellByColumnUniqueName(row, "MLSNum");
  alert('hyperlink = ' + cell.lastChild);                   // displays: hyperlink = http://domain.com
 }
</script>

<ClientSettings EnableRowHoverStyle="true">
<Selecting AllowRowSelect="true" />
<ClientEvents OnRowSelected="RowSelected" />
</ClientSettings>
0
Paul Desormeaux
Top achievements
Rank 1
answered on 29 Sep 2010, 12:05 AM
One approach might be to use a RadBinaryImage inside of a GridTemplateColumn instead of the GridBinaryImageColumn :

                                    <telerik:GridTemplateColumn>
                                        <ItemTemplate>
                                            <a href="http://domain.com">
                                            <telerik:RadBinaryImage
                                                runat="server"
                                                DataValue='<%#Eval("Photo") %>'
                                            />
                                            </a>
                                        </ItemTemplate>
                                    </telerik:GridTemplateColumn>
Tags
Grid
Asked by
tomekm
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Paul Desormeaux
Top achievements
Rank 1
Share this question
or