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

Grid Column and Sprites

4 Answers 71 Views
Grid
This is a migrated thread and some comments may be shown as answers.
MD
Top achievements
Rank 1
MD asked on 19 Jan 2009, 05:06 PM
Is it possible to use the sprites with a grid column such as a GridButtonColumn and if so could you post a code example to show how this could be done.  I was not able to find an example in the documentation for this situation.

Thanks

4 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 20 Jan 2009, 04:56 AM
Hello Matt,

You can access the button for the GridButtonColumn in the code behind, add a CssClass to it and specify the background url in the class accordingly.
cs:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        {            
            ((ImageButton)dataItem["ButtonColumn"].Controls[0]).CssClass = "Button"
        } 
    } 

style.css:
 <style type="text/css"
  .Button 
  { 
    background-image:url('image'); 
  }  
     
  </style> 

For information on Sprite Buttons, you can refer to this link.

Thanks
Princy.
0
MD
Top achievements
Rank 1
answered on 21 Jan 2009, 03:13 PM
Thanks for the response Princy. 

I was wondering though is there a way of handling this declaratively?  When I try to assign the CssClass for the ItemStyle ('rgDel' or 'rgEdit' for instance) of a GridButtonColumn declaratively and set the ButtonType to ImageButton or PushButton it never appears correctly.  It will either show a regular button with the image hidden behind it or in the case of the imagebutton it will show two images stacked and slightly off one another.

Thanks
0
MD
Top achievements
Rank 1
answered on 26 Jan 2009, 09:23 PM
Does anybody know if this is possible?

Thanks
0
Dimo
Telerik team
answered on 27 Jan 2009, 07:47 AM
Hello Matt,

ItemStyle properties are applied to the table cell, while you need to set a CssClass to something inside the cell. For the time being this is not supported declaratively, however, we will implement it for our next release - a ButtonCssClass property for the GridButtonColumn.

In the meantime, you can implement Princy's suggestion.

Kind regards,
Dimo
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
MD
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
MD
Top achievements
Rank 1
Dimo
Telerik team
Share this question
or