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

How to convert boolean fileds to custom template while doing export excel using kendo ui grid

1 Answer 768 Views
Grid
This is a migrated thread and some comments may be shown as answers.
developer
Top achievements
Rank 1
developer asked on 30 Mar 2016, 06:11 AM

Hi..

I'm customizing the boolean fields using template option in kendo column configuration and its working fine.but while doing export excel custom template is getting converted to boolean.

example  :  im having status column of type boolean/number,using template im displaying status as (Active/Inactive/pending).when i do export excel it is displaying as true/false in excel sheet.

Here is the example code with boolean type:

 kendoProperties.addColumnConfiguration({
                    type: "boolean", sortable: false, field: "isPublished", title: "Publish Status", filterable: false,
                    template: "<label class=\"action-status#=isPublished#\">#= (isPublished == false) ? 'NOT PUBLISHED' : 'PUBLISHED' #</label>", width: "150px"
                });

example code with number type:

Parser:

            function parseDataForKendo(result) {
                var data = [];
                productionScheduleListVm.scheduleList = result.results;
                var results = result.results;
                for (var i = 0; i < results.length; i++) {
                    var schedule = {
                        status: results[i].schedule ? results[i].schedule.status : 0,
                        scheduleStatusClass: results[i].schedule.status ? resolveScheduleStatusCssClass(results[i].schedule.status) : null,
                        scheduleStatusText: results[i].schedule.status ? resolveScheduleStatusText(results[i].schedule.status) : null,
                    };
                    data.push(schedule);
                }
                return { "results": data, "totalResults": result.totalResults };
            };

column config:

  kendoProperties.addColumnConfiguration({
                    type: "number", sortable: true, hideWhenMinimize: true, field: "status", title: "Status", filterable: { cell: { template: statusFilter, showOperators: false }},
                    template: "<label class=\"schedule#=scheduleStatusClass# scheduleLabel\">#= (status == null) ? '-NA-' : scheduleStatusText# </label>"
                });

 

1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 01 Apr 2016, 08:35 AM

Hello,

Indeed, as mentioned in the documentation, the column templates are not exported to excel. In case you want to show just a custom text you may follow the link in the documentation to this how-to article which demonstrate how to achieve such functionality. 

Regards,
Rosen
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
developer
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or