I
<div class="panel-body">
@(Html.Kendo().Grid<CdsAdmin.ViewModels.TravelPreferenceVM>()
.Name("gridTravelPreference")
.Columns(columns =>
{
columns.Bound(c => c.TPF_ID).Hidden();
columns.Bound(c => c.TPO_ID).Hidden();
columns.Bound(c => c.TPF_NAME).Filterable(true).Width(200);
columns.Bound(c => c.TPF_DESC).Filterable(false).Width(250);
columns.Bound(c => c.TPF_STATUS).ClientTemplate("# if (TPF_STATUS == 1 ) {# Active #} else {# Inative #}#").Filterable(false).Width(100);
columns.Bound(c => c.TPF_PREFERENCE).ClientTemplate("# if (TPF_PREFERENCE == 1 ) {# <i class='fa fa-heart'></i><i class='fa fa-heart'></i> #} " +
"else if (TPF_PREFERENCE == 2 ) {# <i class='fa fa-heart'></i><i class='fa fa-heart'></i><i class='fa fa-heart'></i> #} " +
"else if (TPF_PREFERENCE == 3 ) {# <i class='fa fa-stars'></i> Exclusive #} " +
"else if (TPF_PREFERENCE == 0 ) {# Neutral #} " +
"else if (TPF_PREFERENCE == -1 ) {# Hidden #} " +
"else {# TPF_PREFERENCE #}#").Filterable(false).Width(200);
columns.Bound(c => c.HTL_CD).Filterable(false);
columns.Bound(c => c.HCH_ID).Filterable(false);
columns.Command(command => { command.Edit().Text(" "); command.Destroy().Text(" "); }).Width(150);
})
.ToolBar(toolbar =>
{
toolbar.Template(@<text>
<a class='k-button k-button-icontext k-grid-excel' href='#'><span class='k-icon k-i-excel'></span>Export Excel</a>
<a class='k-button k-button-icontext k-grid-pdf' href='#'><span class='k-icon k-i-pdf'></span>Export PDF</a>
<a class='k-button k-button-icontext k-grid-add' href='#'><span class='k-icon k-i-add'></span>Add</a>
<a class="k-button k-button-icontext" onclick="addMultiHotels()" style="width:200px;"><span class='k-icon k-i-add'></span>Add multi</a>
</text>);
})
.Editable(editing =>
{
editing.Mode(GridEditMode.PopUp).TemplateName("PopupEditors/PopupTravelPreference")
.Window(w => w.Title("Management preferred hotels").AutoFocus(true));
editing.DisplayDeleteConfirmation("Are you sure ?");
})
.Filterable(ftb => ftb.Mode(GridFilterMode.Row))
.Pageable(pageable => pageable
.Refresh(true)
.PageSizes(false)
.ButtonCount(10))
.Excel(excel => excel.FileName("HotelExcel.xlsx")
.Filterable(true)
.AllPages(true)
.ProxyURL(Url.Action("ExcelExport", "TravelPreference")))
.Pdf(pdf => pdf.AllPages()
.AvoidLinks()
.PaperSize("A4")
.Scale(0.8)
.Margin("2cm", "1cm", "1cm", "1cm")
.Landscape()
.RepeatHeaders()
.TemplateId("pdf-template")
.FileName("HotelPdf.pdf")
.ProxyURL(Url.Action("PdfExport", "TravelPreference")))
.Scrollable()
.Selectable(selectable => selectable.Mode(GridSelectionMode.Multiple)
.Type(GridSelectionType.Cell))
.Navigatable()
.AllowCopy(true)
.Resizable(resize => resize.Columns(true))
.Reorderable(reorder => reorder.Columns(true))
.NoRecords(n => n.Template("Il n'y a pas des hôtels préféré pour cette compagnie."))
.HtmlAttributes(new { style = "height:650px;" })
.Events(events => events.Edit("onKendoGridEdit"))
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(100)
.ServerOperation(true)
.Events(events => events.Error("KendoGridErrorHandler").RequestStart("onRequestStart").RequestEnd("onRequestEnd"))
.Model(model =>
{
model.Id(p => p.TPF_ID);
model.Field(p => p.TPF_ID).Editable(false);
model.Field(p => p.HOTEL).Editable(false);
})
.Create(update => update.Action("Create", "TravelPreference"))
.Read(read => read.Action("Read", "TravelPreference").Data("additionalInfo"))
.Update(update => update.Action("Update", "TravelPreference"))
.Destroy(update => update.Action("Destroy", "TravelPreference"))
))
</div>
My controller
[HttpPost]
public ActionResult ExcelExport(string contentType, string base64, string fileName)
{
var fileContents = Convert.FromBase64String(base64);
return File(fileContents, contentType, fileName);
}
My js
function additionalInfo() {
return {
companyId: CmpId
}
}