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

Export to excel using filter don't ignore case sensitive

1 Answer 44 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Société CompuGROUP Medical Solutions
Top achievements
Rank 1
Société CompuGROUP Medical Solutions asked on 11 Oct 2018, 03:55 PM

The grid ignore case sensitive by default. But when i try to export excel by server side, the datas are filtered but without ignoring the case.
Any thing to do ?

 

 @(Html.Kendo().Grid(Model)
        .Name("grid")
        .ToolBar(toolbar =>
        {
        toolbar.Template(@<text>
            <a class='k-button k-grid-export' title='Export to XLS'>Export vers Excel</a>
        </text>);
        })
        .Columns(columns =>
        {

      columns.Bound(prat => prat.FirstName);
            columns.Bound(prat => prat.LastName);

}

.ColumnMenu()

.Groupable()
.Excel(excel => excel.FileName("Stat.xlsx").Filterable(true).AllPages(true))
.DataSource(dataSource => dataSource
            .Ajax()
            .Model(model => model.Id(p => p.GUIDReference))
            .Read(read => read.Action("DataRead", "BackOffice"))
            .ServerOperation(false)
            )

 

$(".k-grid-export").on("click", function (e) {
            exportToExcel('XLSX');
        });

 function exportToExcel(format) {
            var grid = $("#grid").data("kendoGrid");

            var filteredDataSource = new kendo.data.DataSource({
                data: grid.dataSource.data(),
                filter: grid.dataSource.filter(),               
            });

            filteredDataSource.read();
            var filteredData = filteredDataSource.view();

            var exportOption = {
                format: format,
                title: "Export",
                createUrl: "/BackOffice/Export",
                downloadUrl: "/BackOffice/Download"
            }

            data = {                
                model: JSON.stringify(grid.columns),
                data: JSON.stringify(filteredData.toJSON()),
                format: exportOption.format,
                title: exportOption.title
            };

            $.post(exportOption.createUrl, data, function () {
                window.location.replace(kendo.format("{0}?format={1}&title={2}",
                    exportOption.downloadUrl,
                    exportOption.format,
                    exportOption.title));
            });
        }

1 Answer, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 15 Oct 2018, 11:18 AM
Hello,

It looks to me like the filtering is actually done on the client with this code:
var filteredDataSource = new kendo.data.DataSource({
    data: grid.dataSource.data(),
    filter: grid.dataSource.filter(),              
});
 
filteredDataSource.read();
var filteredData = filteredDataSource.view();

In general, the client-side sort would also be case insensitive.

I tried to reproduce the problem in the attached project but the exported document contains the same data as the Grid, even when I apply filtering using small letters only in the ShipName/ShipCity column prior to the export.

Could you take a look at the project and let me know if I am missing anything important out?

Regards,
Tsvetina
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
Société CompuGROUP Medical Solutions
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Share this question
or