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

[Solved] custom image on header action button

1 Answer 142 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Eva
Top achievements
Rank 1
Eva asked on 15 Dec 2011, 05:58 PM
I would like to use a custom image in the insert command button.  I have tried the following but it has no effect:

.ToolBar(cmd =>

{

cmd.Insert().ButtonType(

GridButtonType.Image).ImageHtmlAttributes(new { src="~/Content/Common/Images/Icons/add.png", width="24", height="24" });

})

Is there a way to do this?

Thanks!

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 16 Dec 2011, 02:13 PM
Hi Eva,

The "image" inside the button is actually not an image, but a <span> element.

<span class="t-icon "></span>

The idea is that you should apply a background image style to it, possibly from a sprite ( http://www.w3schools.com/css/css_image_sprites.asp ).

For example, if you take the following demo as a starting point:

http://demos.telerik.com/aspnet-mvc/grid/customcommand

and use:

Html.Telerik().Grid(Model)
     .Name("Grid")
     .ToolBar(commands => commands
         .Custom()
             .ButtonType(GridButtonType.Image)
             .ImageHtmlAttributes(new { @class = "t-icon t-refresh"})
             .Text("Text"))

You will see the result. We recommend using CSS classes and defining all required styles (size and background) externally.

All the best,
Dimo
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
Tags
Grid
Asked by
Eva
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or