Hi
I'm using 2014.3.1119.440 version of Kendo MVC UI.
I configured the grid to export all data and a custom filename, and a custom toolbar with export to excel button.
It works fine, when I don't restore grid options using setOptions function.
When I restore it, with my custom toolbar preserve, it looks, like the export options are ignored.
There are only records from current page exported and exported file has a standard name.
I found the settings are correct in the page source.
Do I need some extra steps to make the settings working after restoring grid options?
Here's my razor grid code:
and here's the part of my javascript for saving and restoring grid options:
I restore the settings on page load:
Thanks in advance.
Paweł
I'm using 2014.3.1119.440 version of Kendo MVC UI.
I configured the grid to export all data and a custom filename, and a custom toolbar with export to excel button.
It works fine, when I don't restore grid options using setOptions function.
When I restore it, with my custom toolbar preserve, it looks, like the export options are ignored.
There are only records from current page exported and exported file has a standard name.
I found the settings are correct in the page source.
Do I need some extra steps to make the settings working after restoring grid options?
Here's my razor grid code:
@{ Html.Kendo().Grid<Vectra.CPN.CPNLibrary.ViewModel.TRANSFER_IN_V>() .Name("MainGrid") .ToolBar(toolBar => toolBar.Template(@<text> <input class="t-button" type="button" id="ShowCreateNewExtFormId" name="ShowCreateNewExtForm" value="@Resources.Create" onclick="location.assign('@Url.Content("~/" + ControllerName + "/New")')"/> <input class="t-button" type="button" id="ShowEditFormId" name="ShowEditForm" value="@Resources.Edit" /> <input class="t-button" type="button" id="ShowDetailFormId" name="ShowDetailForm" value="@Resources.Details" /> <a class="k-button k-button-icontext k-grid-excel" href="#"><span class="k-icon k-i-excel"></span>Zapisz do Excela</a> <a href="" class="k-button" id="save">Save View</a> <a href="" class="k-button" id="load">Restore View</a> </text>) ) .Excel(ex => ex.AllPages(true).FileName("cpn_do_vectry_" + DateTime.Now.ToShortDateString() + ".xlsx")) .ColumnMenu(column => column.Columns(true)) .Columns(columns => columns.LoadSettings((IEnumerable<GridColumnSettings>)ViewBag.GridColumns)) .Reorderable(reorder => reorder.Columns(true)) .Sortable(sortable => sortable.Enabled(true).SortMode(GridSortMode.SingleColumn).AllowUnsort(true)) .Pageable(pageable => pageable.Enabled(true).Refresh(true).ButtonCount(5).PageSizes(true).PageSizes(new int[] { 5, 10, 20, 50 })) .Filterable(filtering => filtering.Enabled(true)) .Selectable(s => s.Mode(Kendo.Mvc.UI.GridSelectionMode.Single).Type(GridSelectionType.Row)) .Events(events => events.Change("onChange")) .DataSource(dataSource => dataSource .Ajax() .Read(read => read.Action("TransferIn_Read", "TransferIn")) .Model(model => model.Id(o => o.TRANSFER_ID)) .ServerOperation(false) ) .AutoBind(false) .Render() ;}and here's the part of my javascript for saving and restoring grid options:
var localStorageKey = "MainTransferInOptions";var areOptionsLoaded = false;function bindSaveRestoreCliks(){ var grid = $("#MainGrid").data("kendoGrid"); $("#save").click(function (e) { e.preventDefault(); localStorage[localStorageKey] = kendo.stringify(grid.getOptions()); }); $("#load").click(function (e) { e.preventDefault(); loadGridOptions(e); });}function loadGridOptions(e){ if (e == undefined || e.type == "click" || (!areOptionsLoaded && e.type == "read")) { var rawGrid = $("#MainGrid"); var grid = $("#MainGrid").data("kendoGrid"); var options = localStorage[localStorageKey]; var toolbar = $("#MainGrid").find(".k-grid-toolbar").html(); if (options) { grid.setOptions(JSON.parse(options)); } else if (!areOptionsLoaded && e == undefined) { grid.dataSource.read(); } var newtoolbar = $("#MainGrid").find(".k-grid-toolbar"); $("#MainGrid").find(".k-grid-toolbar").html(toolbar); bindSaveRestoreCliks(); areOptionsLoaded = true; } }I restore the settings on page load:
$(window).ready(function (e) { loadGridOptions(undefined);});Thanks in advance.
Paweł