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

[Solved] Specifying button image

3 Answers 304 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.
Brian Roth
Top achievements
Rank 1
Brian Roth asked on 02 Sep 2010, 10:04 PM
I noticed that in the latest build we can set the grid buttons to show images instead of text.  Thanks!  For custom buttons, what would be the easiest way to define an image?  Can this be done in the View definition where the button is set up or would I need to use some jQuery logic to set the image?

As always, thanks for the help.

Regards,
Brian

3 Answers, 1 is accepted

Sort by
0
Accepted
Alex Gyoshev
Telerik team
answered on 03 Sep 2010, 02:58 PM
Hello Brian,

You should add the icons through CSS, like this:

 View

.ToolBar(toolbar => {
    toolbar.Custom()
        .Text("Custom command")
        .HtmlAttributes(new { @class = "my-custom-command" })
        .ButtonType(GridButtonType.ImageAndText);
})

CSS

.my-custom-command .t-icon {
    background: transparent url('my-custom-icon.png') no-repeat 0 0;
}


All the best,
Alex Gyoshev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Brian Roth
Top achievements
Rank 1
answered on 07 Sep 2010, 11:22 PM
Perfect.  Thanks!
0
Chris McNear
Top achievements
Rank 1
answered on 30 Jan 2012, 07:31 PM
I can't get this to work any help would be appreciated...

View :
columns.Command(commands => commands.Custom("ViewStory")
                                .Text("View Story")
                                .DataRouteValues(route => route.Add(story => story.StoryId).RouteKey("StoryId"))
                                .Ajax(true)
                                 .HtmlAttributes(new { @class = "viewDetailsCommand" })
                                .Action("DisplayStory", "Admin").ButtonType(GridButtonType.Image));

Style tag in same page....

<style type="text/css">
    .viewDetailsCommand.t-icon
    {
        background: transparent url('~/Content/mglass.jpg') no-repeat 0 0;
    }
</style>


but all I get is a blank box.  don't suppose there is a default "view" icon we can use instead?
Tags
Grid
Asked by
Brian Roth
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Brian Roth
Top achievements
Rank 1
Chris McNear
Top achievements
Rank 1
Share this question
or