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

How to add configuration options in Javascript

2 Answers 48 Views
Grid
This is a migrated thread and some comments may be shown as answers.
PJ Melies
Top achievements
Rank 1
PJ Melies asked on 26 Apr 2016, 11:07 PM

I have a grid that includes the Export to Excel functionality.

I retrieve the grid options via getOptions() and store them to local storage so that I may later restore those settings by using setOptions().  The  Export to Excel button is not being displayed after I call setOptions() so I'm assuming this is something I need to manually add to the configuration.  However, I'm having a hard time coming up with the syntax.  How do I do this?

The relevant configuration of the grid looks like this:

.ToolBar(tools => tools.Excel())
.Excel(excel => excel
    .AllPages(true)
    .FileName("Applications.xlsx")
    .Filterable(true)
    .ProxyURL(Url.Action("Excel_Export_Save", "Application"))
)

 

Code to populate the grid options looks like this:

var options = JSON.parse(gridOptions);
 
// Now that I have the options how do I add the Excel settings I defined on the
// grid above before calling setOptions()?
 
grid.setOptions(options);

2 Answers, 1 is accepted

Sort by
0
Accepted
Dimiter Madjarov
Telerik team
answered on 28 Apr 2016, 08:00 AM

Hello PJ Melies,

This issue is expected and the reason is that the toolbar template is built on the server side in this case and not stored in the configuration. The applicable workaround is demonstrated in the following sample project.

Regards,
Dimiter Madjarov
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
PJ Melies
Top achievements
Rank 1
answered on 03 May 2016, 08:49 PM
Thank you Dimiter.  This is exactly what I was looking for.
Tags
Grid
Asked by
PJ Melies
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
PJ Melies
Top achievements
Rank 1
Share this question
or