Given the following definition in a Radgrid column:
<telerik:GridBinaryImageColumn DataField="ReceiptThumb" HeaderText="Receipt Image" UniqueName="ReceiptThumb" ResizeMode="Fit" ImageWidth="100" ImageHeight="100" />
What would be the best way to add a click event which would either 1) open a new window in a _blank target frame, or 2) open a radwindow on the same page -- to allow a full-size image of the thumbnail displayed in the grid to display?
... while not disturbing the in-place edit form insert/edit functionality?
3 Answers, 1 is accepted
Which is best, is relative to the environment, rules, habits, etc. You can add the click event to the cell either on the server or client side, you choose.
If the click needs to be added at loading time, Page load might be too early, sometimes the grid isn't ready yet. Best is to use the GridCreated client-side event of RadGrid. This event fires when rendering the grid is over.
There are two approaches you can try, one of which is using jQuery to find the cells then add the click event, or using the RadGrid's client-side APIs to loop through the items and find the cell.
RadGrid client-side API.
Using JQuery within the GridCreated event handler. To have proper selectors, add a CSS class name to the GridBinaryImageColumn using the ItemStyle-CssClass property.
Server-Side using the ItemCreated event of RadGrid. (For more information, please check out the Accessing Cells and Rows article)
Finally, the cellClick event handler.
I hope this will help.
That is another way to go. Although it is not a good practice clearing controls as it may cause unexpected behavior at some point.
Also, accessing the row cells by index could cause problems if the column structure is changing. The index would no longer be valid and results in errors. Try accessing the cell by using the Column unique name.