I am not sure if this is by design but when i click on button that exports to excel when the grid has no data, it invokes the ajax read call first and then export the result in excel. If the grid already has the result, it seems like it doesn't call the read function and it exports the result right away.
In the following code, 'GetPurchaseOrders' gets invoked whenever excel button is clicked whenever excel to export button is clicked.
Any idea why this is happening?
Thanks.
@(Html.Kendo().Grid<
SupplierPortal.ViewModels.PoViewModel
>()
.Name("GridPOSearchHeaderInfo")
.Columns(columns =>
{
columns.Bound(e => e.Revision).Width("120px").HtmlAttributes(new { @style = "text-align:right;" });
columns.Bound(e => e.SupplierNumber).Width("170px").HtmlAttributes(new { @style = "text-align:right;" });
columns.Bound(e => e.SupplierName).Width("160px");
})
.Excel(excel => excel
.FileName("PurchaseOrders.xlsx")
.ProxyURL(Url.Action("Excel_Export_Save", "Supplier"))
.AllPages(true)
)
.ToolBar(tools =>
{
tools.Template(@<
text
>
<
div
class
=
"col-lg-1 col-md-2 col-sm-2 col-xs-4 pull-right"
style
=
"padding-left: 0; margin-top: 2px; text-align: right;"
>
@Html.ActionLink(" ", "SaveView", "PurchaseOrder", null, new { @class = "modal-link k-button POcolumn", @style = "padding-left: 10px;", @title = "Customize Grid" })
<
a
class
=
"k-button k-button-icontext k-grid-excel POexport"
href
=
"#"
style
=
"padding-left: 10px;"
title
=
"Export to Excel"
><
span
class
=
"k-icon k-i-excel"
></
span
></
a
>
</
div
>
</
text
>);
})
.Pageable(x => x.PageSizes(new int[] { 10, 20, 50, 100 }).ButtonCount(4))
.Reorderable(reorder => reorder.Columns(true))
.AutoBind(false)
.Sortable(sortable => sortable
.AllowUnsort(true)
.SortMode(GridSortMode.MultipleColumn))
.Selectable()
.ColumnMenu()
.Scrollable(scr => scr.Height(322))
.Filterable(filterable => filterable
.Extra(false)
.Operators(operators => operators
.ForString(str => str.Clear()
.Contains("Contains")
.StartsWith("Starts with")
.IsEqualTo("Is equal to")
.IsNotEqualTo("Is not equal to")
))
)
.Resizable(resize => resize.Columns(true))
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(10)
.Read(read => read.Action("GetPurchaseOrders", "PurchaseOrder").Data("GetSearchParameters"))
.ServerOperation(false)
)
.Events(events => events.DataBound("gridDataBound"))
.Events(events => events.DataBinding("gridDataBinding"))
)