
Hello telerik, First of all thanks a lot for good components!
But I have a small problem:
I use my custom column (inherit from BoundColumn) in RadGrid which show small thumbnail image (When user click to Image new browser window is opened and show full - size image). During OnItemDataBound event I rewrite default Controls container of custome Column, by adding HyperLink control for showing thumbnail image.
Besides my Grid has an grouping ability. But when I try to expand/collapse my groupped data I can't see thumbnail images in cell because OnItemDataBound doesn't raised. In this case I call RadGrid.Rebind() in OnItemCommand handler, but function doesn't work properly - Groupping item doesn't expand/collapse. Or one item is collapse but another expand. How can I support Custom Column data binding and expand/collapse support?
Please Help.
5 Answers, 1 is accepted
Please add desired controls using ItemCreated instead ItemDataBound.
Regards,
Vlad
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.

You can add the controls to the grid column cells intercepting the ItemCreated event and bind those controls to data hooking the ItemDataBound event of the control. Review the following topic from the documentation which explains the major differences between both events:
http://www.telerik.com/help/aspnet-ajax/grddistinguishdifferencesbetweenitemcreateditemdatabound.html
Best regards,
Stephen
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.

Not sure, that topic can help to me. All point in it is clear. I have modified my code: transfer creation of HyperLink in cell from
OnItemDataBound to OnItemCreated. I am just add a HyperLink to a GridDataItem["ImageColumn"].Controls without ANY binding operation:
protected override void OnItemCreated(GridItemEventArgs e) |
{ |
base.OnItemCreated(e); |
if (e.Item is GridDataItem && Page.IsPostBack) |
{ |
GridDataItem dataItem = e.Item as GridDataItem; |
HyperLink link = new HyperLink(); |
dataItem["ImageColumn"].Controls.Add(link); |
dataItem["ImageColumn"].HorizontalAlign = HorizontalAlign.Center; |
link.ImageUrl = "LinkUrl"; //Url to thubmnail image |
link.NavigateUrl = "NavigateUrl"; //Url to open full-size image |
link.Target = "imageWindow"; |
} |
} |
It's looks good - but when page is Loaded I don't see any Links - just a System.Byte[]. I don't need bind any data to my created HyperLink, how can I skip binding for specific cell? |
Consider clearing the controls from the Controls collection of the set prior to adding the HyperLink to it, namely:
protected override void OnItemCreated(GridItemEventArgs e) |
{ |
base.OnItemCreated(e); |
if (e.Item is GridDataItem && Page.IsPostBack) |
{ |
GridDataItem dataItem = e.Item as GridDataItem; |
dataItem["ImageColumn"].Controls.Clear(); |
HyperLink link = new HyperLink(); |
dataItem["ImageColumn"].HorizontalAlign = HorizontalAlign.Center; |
link.ImageUrl = "LinkUrl"; //Url to thubmnail image |
link.NavigateUrl = "NavigateUrl"; //Url to open full-size image |
link.Target = "imageWindow"; |
dataItem["ImageColumn"].Controls.Add(link); |
} |
} |
Thus you should be able to skip the default binding mechanism for controls residing in the respective grid cell.
Kind regards,
Stephen,
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.