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

KENDO MVC Grid toolbar: excel export button + template button?

10 Answers 2867 Views
Grid
This is a migrated thread and some comments may be shown as answers.
reader
Top achievements
Rank 1
reader asked on 06 Feb 2015, 05:39 AM
I'm using this to add template in toolbar of kendo ui mvc grid.

.ToolBar(toolbar =>{
                toolbar.Template(@<text>
                        ...
                    </text>);
                })

I can also use this to add a default excel export button:
.ToolBar(toolbar => toolbar.Excel())

Is it possible to add the excel export button, then add template (buttons) after excel button?

or, we will have to use one template button and export excel file in code?


Thanks

10 Answers, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 06 Feb 2015, 02:39 PM

Hello Reader,

When a template is used, you should directly include the excel export command button mark up to the template.
E.g.

<a class="k-button k-button-icontext k-grid-excel" href="#"><span class="k-icon k-i-excel"></span>Export to Excel</a>

Regards,
Dimiter Madjarov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
reader
Top achievements
Rank 1
answered on 06 Feb 2015, 04:23 PM
I guess: The Grid will recognize the button by it's k-grid-excel CSS class.

any other k-grid css class we can use? I want to add a refresh button to toolbar and want to have consistent look and feel.

Thanks
0
Dimiter Madjarov
Telerik team
answered on 09 Feb 2015, 01:18 PM

Hello Reader,

This is correct. Indeed you could use the same approach with any toolbar command e.g. create, save, cancel. Nevertheless the refresh command is part of the pager and cannot be added this way. As a workaround you could add a custom button and manually invoke the refresh method of the Grid API in it's click handler.

Regards,
Dimiter Madjarov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Donald
Top achievements
Rank 1
answered on 12 Feb 2015, 05:18 PM
When adding the excel export command button mark up to the template, how does one set properties such as .AllPages(true)?
0
Donald
Top achievements
Rank 1
answered on 12 Feb 2015, 05:40 PM
Got it! For anyone else in need, here's how I did it:

In grid onDataBound event put this line: this.element.data('kendoGrid').getOptions().excel or .pdf()
This will expose the properties which can then be manipulated via js/jQuery:
allPages     false
fileName     "Export.xlsx"
filterable     false
proxyURL   ""
0
Dimiter Madjarov
Telerik team
answered on 13 Feb 2015, 08:43 AM

Hello Donald,

These properties could be set directly in the Grid configuration via the excel configuration option.

Have a great day!

Regards,
Dimiter Madjarov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Rasika
Top achievements
Rank 1
answered on 07 Jul 2015, 11:39 AM

I am getting an error when i am adding toolbar.excel()

Error 3 'Kendo.Mvc.UI.Fluent.GridToolBarCommandFactory<SampleUIApp.Areas.ListPage.Models.AccntGroupModel>' does not contain a definition for 'Excel' and no extension method 'Excel' accepting a first argument of type 'Kendo.Mvc.UI.Fluent.GridToolBarCommandFactory<SampleUIApp.Areas.ListPage.Models.AccntGroupModel>' could be found (are you missing a using directive or an assembly reference?) d:\users\rasika.telang\TFS2013\SandBox\Projects\SampleUIApp\SampleUIApp\Areas\ListPage\Views\AccntGroup\IndexListPageExportExcel.cshtml 17 29 SampleUIApp

 

what do i do?

@Dimiter

0
Dimiter Madjarov
Telerik team
answered on 07 Jul 2015, 12:36 PM

Hello Rasika,

Please open a support ticket about the problem, so we could assist with the issue.

Regards,
Dimiter Madjarov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Tester
Top achievements
Rank 1
answered on 01 May 2020, 04:26 PM

Can we hide the kendo grid exort to excel button for some users?

 

0
Silviya Stoyanova
Telerik team
answered on 05 May 2020, 01:18 PM

Hello Neema,

There is no built-in functionality that could be applied. A possible solution could be based on the user's role to enable/disable the excel export. Use the HtmlAttributes to add class "user".

@{
    var user = "Admin";
}
.ToolBar(t => t.Excel().HtmlAttributes(new { @class = @user }))

and then apply a CSS style to:

.Admin {
display:none 
}

Let me know in case you need further assistance.

Kind Regards, Silviya Stoyanova Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
Grid
Asked by
reader
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
reader
Top achievements
Rank 1
Donald
Top achievements
Rank 1
Rasika
Top achievements
Rank 1
Tester
Top achievements
Rank 1
Silviya Stoyanova
Telerik team
Share this question
or