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

Exporting to Excel with dot syntax fieldnames

4 Answers 104 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Iron
Alex asked on 21 Apr 2015, 12:09 PM

Hi

I have a grid which exports perfectly to Excel but throws an exception as soon as I add a field with a name using dot syntax like:

'["Toponym.id"]'

Is there a work around or a bug fix for this caes?

Regards

Alex

 

4 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 23 Apr 2015, 07:28 AM
Hi Alex,

Could you please paste here your grid configuration? We need that to reproduce the error you are having.

Regards,
Atanas Korchev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Alex
Top achievements
Rank 1
Iron
answered on 23 Apr 2015, 07:54 AM

Hi

the grid is configured like this:

 

toponymGrid = $("#toponym_grid").kendoGrid({
            dataSource: toponymDataSource,
            sortable: true,
            editable: "popup",
            resizable: true,
            pageable: false,
            selectable: true,
            dataBound: dataBoundHandler,
            toolbar: kendo.template($("#toponym-toolbar-template").html()),
            excel: {
                allPages: true
            },
            columnMenu: {
                messages: {
                    sortDescending: "Absteigend",
                    sortAscending: "Aufsteigend",
                    columns: "Spalten"
                }
            },
            filterable: {
                name: "Filter",
                extra: true, // turns on/off the second filter option
                messages: {
                    info: "Wähle Einträge die:", // sets the text on top of the filter menu
                    filter: "Filter", // sets the text for the "Filter" button
                    clear: "Löschen", // sets the text for the "Clear" button
 
                    // when filtering boolean numbers
                    isTrue: "custom is true", // sets the text for "isTrue" radio button
                    isFalse: "custom is false", // sets the text for "isFalse" radio button
                    and: "und",
                    or: "oder"
 
                },
                operators: {
                    //filter menu for "string" type columns
                    string: {
                        startswith: "beginnen mit",
                        eq: "sind gleich",
                        neq: "sind nicht gleich",
                        contains: "enthalten",
                        endswith: "enden mit"
                    },
                    //filter menu for "number" type columns
                    number: {
                        eq: "identisch mit",
                        neq: "nicht identisch mit",
                        gte: "grösser oder gleich",
                        gt: "grösser als",
                        lte: "kleiner oder gleich",
                        lt: "kleiner als"
                    },
                    //filter menu for "date" type columns
                    date: {
                        eq: "Custom Equal to",
                        neq: "Custom Not equal to",
                        gte: "Custom Is after or equal to",
                        gt: "Custom Is after",
                        lte: "Custom Is before or equal to",
                        lt: "Custom Is before"
                    }
                }
            },
            columns: [{
                    field: "id",
                    title: "id",
                    width: 100,
                    hidden: true
                },
                {
                    field: 'toponym',
                    title: "Flurname",
                    width: 120
                },
                {
                    field: '["Community.name"]',
                    title: "Gemeinde",
                    width: 100
                },
                {
                    field: "['Canton.abbreviation']",
                    title: "Kanton",
                    width: 80
                },
                {
                    field: 'dictions',
                    title: "Schreibweisen"
                },
                {
                    command: [{text: "Edit", click: updateToponym}, {text: "Delete", click: deleteToponym}],
                    title: "Flurname", width: "160px"
                }
            ]
        }).data("kendoGrid");

 

I export to excel using grid.saveAsExcel and I get the exception:
SyntaxError: missing ) in parenthetical
Source file: http://improbabilitydrive.ch/toponym/app/resource/js/kendoui/js/kendo.all.min.js
Source: return ((d["Community || {}).name"])

 

Regards

Alex

0
Atanas Korchev
Telerik team
answered on 23 Apr 2015, 08:25 AM
Hello Alex,

Thank you for providing the code. It helped us reproduce the problem.

Please paste this code before your grid declaration. 

var kendo_expr = kendo.expr;
    
    kendo.expr = function(value, safe) {
      value = value.replace(/"([^.]*)\.([^"]*)"/g,'"$1__DOT__$2"');
      value = value.replace(/'([^.]*)\.([^']*)'/g,"'$1__DOT__$2'");
      return kendo_expr(value, safe).replace(/__DOT__/g, ".");
    }

This should fix the issue until we address it with a patch. Here is a live demo: http://dojo.telerik.com/@korchev/UyUca

Regards,
Atanas Korchev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Alex
Top achievements
Rank 1
Iron
answered on 23 Apr 2015, 08:27 AM

What can I say?

Your framework and your support are simply amazing.
Thank you very much!!

Regards Alex

 

 

Tags
Grid
Asked by
Alex
Top achievements
Rank 1
Iron
Answers by
Atanas Korchev
Telerik team
Alex
Top achievements
Rank 1
Iron
Share this question
or