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

[Solved] Custom Image Column?

7 Answers 409 Views
Grid
This is a migrated thread and some comments may be shown as answers.
sitefinitysteve
Top achievements
Rank 2
Iron
Iron
Veteran
sitefinitysteve asked on 05 Dec 2008, 06:00 PM
My grid is databound, and the last 3 columns give me a status text message (approved, rejected, etc, etc)

Can I make a new column after that (non-databound) which just checks the status, then I can insert a corrosponding image?  Like a checkmark if all 3 are approved for example...

Regards,
Steve

7 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 08 Dec 2008, 07:25 AM
Hi Steve,

Please check the last column in this example:
http://demos.telerik.com/aspnet-ajax/Grid/Examples/Programming/WebMail/DefaultCS.aspx

Best wishes,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Princy
Top achievements
Rank 2
answered on 08 Dec 2008, 07:58 AM
Hi Steve ,

You can use a GridTemplateColumn to achieve the desired scenario.

ASPX:
<telerik:GridTemplateColumn UniqueName="TempCol" HeaderText="TempCol"   > 
                          <ItemTemplate> 
                          
                          </ItemTemplate> 
                        </telerik:GridTemplateColumn> 

CS:
 
 protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)  
    {  
        if (e.Item is GridDataItem)  
        {  
            GridDataItem item = (GridDataItem)e.Item;  
            string strcol1 = item["BoundCol1"].Text.ToString();  
             string strcol2 = item["BoundCol2"].Text.ToString();  
             if ((strcol1 == strcol2) && (strcol1 == "approved"))  
             {   
                 Image img=new Image();  
                 img.ID="Image1";  
                 img.ImageUrl="~/Images/Check.gif";  
                 item["TempCol"].Controls.Add(img);  
             }  
        }  
 
 

Thanks
Princy

0
Maxim Tairov
Top achievements
Rank 1
answered on 20 May 2009, 02:41 PM
Possible there is a sample of How to Create Custom Image column (column for showing images) without useg Template Column?
0
Sebastian
Telerik team
answered on 20 May 2009, 02:57 PM
Hello Maxim,

In the present version of RadGrid for ASP.NET AJAX you can use only a template column for this purpose.

However, you may be happy to know that we plan to introduce new built-in GridImageColumn for the next version of the product, expected in the beginning of July. With it you will be able to specify image url fields and image url format string to display different images in the same column.

Best regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Maxim Tairov
Top achievements
Rank 1
answered on 20 May 2009, 03:07 PM

Hello Sebastian!

I would be greate! because my customer wants to see small preview of Image, which was stored in database - by clicking of Images I show full-size Image. But my custom solution deosn't work properly.

0
Sebastian
Telerik team
answered on 20 May 2009, 03:47 PM
Hello Maxim,

Unfortunately images thumbnails with preview option will not be supported by that new grid column.

However, you may consider intercepting the onclick client event of the image from within the ItemCreated event of the grid and display it in full size inside RadWindow instance with approach similar to this one (using asp Image instead of Hyperlink inside the template column).

Kind regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Maxim Tairov
Top achievements
Rank 1
answered on 20 May 2009, 06:55 PM
Hello Sebastian,
So, I've just wrote about my actual task. My aim is to put special link on aspx page for showing image in cell. Server page will put small preview image into output stream .... Thing that new GridImageColumn can help me in this problem, and sure In any cases there are 'good' events:  ItemCreated, ItemDataBound.

Thanks a lot for supporting, and for Great UI library.
Tags
Grid
Asked by
sitefinitysteve
Top achievements
Rank 2
Iron
Iron
Veteran
Answers by
Vlad
Telerik team
Princy
Top achievements
Rank 2
Maxim Tairov
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or