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

Templated button and pdf/excel export buttons in Grid

2 Answers 476 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ian
Top achievements
Rank 1
Ian asked on 21 Nov 2014, 11:38 AM
I'm using the latest version of UI for ASP.NET MVC (2014.3.1119)

How do I get a templated button and the export to excel/pdf buttons in a grid toolbar. I can get either the customs buttons OR the pdf/excel buttons, but if I specify both, the excel/pdf buttons do not appear. A similar issue exists with the create button and a templated button, but this can be fixed using @item.CreateButton() in the template definition instead of tb.Create();

So in the code snippet below, I just get the "Create New" button. If I remove that button, I get the Excel and pdf buttons.

.ToolBar(tb =>
{
    tb.Excel();
    tb.Pdf();                          
    tb.Template(@<text>@Html.ActionLink("Create New", "Create", null, new {@class = "btn btn-primary btn-xs pull-right"})</text>);
})

Thanks,

Ian

2 Answers, 1 is accepted

Sort by
0
Ian
Top achievements
Rank 1
answered on 21 Nov 2014, 01:00 PM
I'll answer my own question as I found out how to achieve what I wanted. The answer in my case was to use tb.Custom thus:

.ToolBar(tb =>
{
    tb.Custom().Name("Create New").Url(@Url.Action("Create")).HtmlAttributes(new {@class = "btn btn-primary btn-xs pull-right"});
    tb.Excel().HtmlAttributes(new {@class = "btn btn-primary btn-xs pull-right"});
    tb.Pdf().HtmlAttributes(new {@class = "btn btn-primary btn-xs pull-right"});
})
0
Sergey
Top achievements
Rank 2
answered on 21 Nov 2014, 09:16 PM
Wonder what format this is supposed to take if the template is more complex and can't be avoided as in your answer. 
Tags
Grid
Asked by
Ian
Top achievements
Rank 1
Answers by
Ian
Top achievements
Rank 1
Sergey
Top achievements
Rank 2
Share this question
or