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

Toolbar custom command's image not show?

2 Answers 120 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.
Nick Wu
Top achievements
Rank 1
Nick Wu asked on 11 Apr 2011, 10:32 AM
Because new record content is so complex , I create new record using single view page.
it seemed that the grid toolbar's default insert command can't be used to redirect other page.
So I use the custom command like below.
ToolBar(commands => commands.Custom().Text("Create New SaleOrder").Action("Create", "SaleOrder").ButtonType(GridButtonType.ImageAndText))
the command works well, but there is no image be showed on the button.
Can I add image to button?



2 Answers, 1 is accepted

Sort by
0
Victor
Top achievements
Rank 1
answered on 08 Jul 2011, 09:59 AM
Hi!

We have the exact same issue, have you found any solution on how to add an icon to a custom command button yet?

Thanks
/Victor
0
Dimo
Telerik team
answered on 08 Jul 2011, 11:33 AM
Hello,

If the ButtonType is ImageAndText, the custom command will render a <span> element, however, you will also need to define a (custom) CSS class by using ImageHtmlAttributes. The CSS class will set some background image. For example:

.ToolBar(commands => commands
    .Custom()
        .ButtonType(GridButtonType.ImageAndText)
        .ImageHtmlAttributes(new { @class = "t-icon t-edit"})
        .Text("button text"))

Finally, note that the above functionality did not work well until recently, so you need to use the latest internal build or the Q2 2011 Beta.

Kind regards,
Dimo
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
Grid
Asked by
Nick Wu
Top achievements
Rank 1
Answers by
Victor
Top achievements
Rank 1
Dimo
Telerik team
Share this question
or