Shahood Amir
Shahood Amir

Reputation: 5

Add Filter on Specific Kendo Grid and Exporting it as Excel

I have a Kendo Grid where I have the option to export the Data in .xlxs file.

I want to add .filterable(true) for a specific column SortDate but current code adds filter on all column names

<div class="row">
<div class="col-md-12 col-xs-18">
    @(Html.Kendo().TabStrip().Name("tabstrip")
        .Animation(animation => animation.Open(effect => effect.Fade(FadeDirection.In)))
        .Items(tabstrip =>
        {
            tabstrip.Add().Text("FiT").Selected(true).Content(@<text>@(Html.Kendo().Grid<usp_Get_TransactionTypeReport_Result>
                ()
                .Name("gvTransactionTypeReport")
                .Columns(columns =>
                {
                    columns.Bound(p => p.SortDate).Title(Sd.T("grid.sortdate")).ClientFooterTemplate("Total").ClientTemplate("#= kendo.toString(SortDate, \"MM/dd/yyyy\") #").Filterable(true);
                    columns.Bound(p => p.CheckInToLocation).Title(Sd.T("grid.CheckInToLocation")).ClientFooterTemplate("#=sum#").Filterable(false);
                    columns.Bound(p => p.CheckOutToUser).Title(Sd.T("grid.CheckOutToUser")).ClientFooterTemplate("#=sum#").Filterable(false);
                    columns.Bound(p => p.Destroyed).Title(Sd.T("Destroyed")).ClientFooterTemplate("#=sum#").Filterable(false);
                    columns.Bound(p => p.Transferred).Title(Sd.T("Transferred")).ClientFooterTemplate("#=sum#").Filterable(false);
                    columns.Bound(p => p.RequestedFiles).Title(Sd.T("grid.RequestedFiles")).ClientFooterTemplate("#=sum#").Filterable(false);
                    columns.Bound(p => p.FilesCreated).Title(Sd.T("grid.FilesCreated")).ClientFooterTemplate("#=sum#").Filterable(false);
                    columns.Bound(p => p.BoxCreated).ClientFooterTemplate("#=sum#").Filterable(false).Title(Sd.T("grid.BoxCreated"));
                })
                .ToolBar(x =>
                {
                    x.Excel().HtmlAttributes(new { @class = "pull-right" }).Text(Sd.T("exporttoexcel"));
                })
                .Excel( excel => excel.FileName("StatisticalReport.xlsx")
                                      .Filterable(true)
                                      .ProxyURL(Url.Action("ExportExcel", "Master"))
                )
                .Filterable()
                .DataSource(dataSource => dataSource
                .Ajax()
                .ServerOperation(false)
                .Aggregates(aggregates =>
                {
                    aggregates.Add(p => p.CheckInToLocation).Sum();
                    aggregates.Add(p => p.CheckOutToUser).Sum();
                    aggregates.Add(p => p.Destroyed).Sum();
                    aggregates.Add(p => p.Transferred).Sum();
                    aggregates.Add(p => p.RequestedFiles).Sum();
                    aggregates.Add(p => p.FilesCreated).Sum();
                    aggregates.Add(p => p.BoxCreated).Sum();
                })
                .Read(read => read.Action("TransactionTypeReport_Read", "Reports"))
                )
            )</text>);
        }
    ))

</div>

Do I have to write custom JavaScript for this purpose or is there a default functionality for that?

Upvotes: 0

Views: 18

Answers (0)

Related Questions