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

Grid with Spaces in Column Name

4 Answers 1288 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Feyzi
Top achievements
Rank 1
Feyzi asked on 10 Apr 2015, 07:46 AM
Kendo Grid fails to display or export anything if there is a space in a JavaScript
Property. We are in need of such column names because we display tables of a
database with such column names (we do not have control over this).

4 Answers, 1 is accepted

Sort by
0
Feyzi
Top achievements
Rank 1
answered on 10 Apr 2015, 08:47 AM
I’ve been able to fix it, yet I do not know whether this is a good solution. On line 2502
in kendo.core.js, in the kendo.expr function, I added two lines:
expr: function(expression, safe, paramName) {

            expression = expression || "";
            if (typeof safe == STRING) {
                paramName = safe;
                safe = false;
            }

            paramName = paramName || "d";

            if (expression && expression.charAt(0) !== "[" && expression.indexOf(' ') !== -1)

                expression = '[\'' + expression + '\']';

            if (expression && expression.charAt(0) !== "[") {

                expression = "." + expression;

            }

 

0
Rosen
Telerik team
answered on 14 Apr 2015, 07:31 AM
Hi Feyzi,

Having spaces in the field name is only supported if the correct syntax is used in the column declaration. For example:

$("#grid").kendoGrid({
  columns: [ {
       field: '["Category Name"]',
       title: "Category Name"
  }]
});


Regards,
Rosen
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Santosh
Top achievements
Rank 2
commented on 22 Jun 2021, 05:41 AM

Is this working for Aggregation?
Santosh
Top achievements
Rank 2
commented on 22 Jun 2021, 05:50 AM

Bill Amount
ApmcReportTelerikViewController.js:358 {field: "[\"Bill Amount\"]", title: "Bill Amount", aggregates: "[\"count\"]", footerTemplate: "Count: #: sum #"}aggregates: "[\"count\"]"field: "[\"Bill Amount\"]"footerTemplate: "Count: #: sum #"title: "Bill Amount"__proto__: Object
angular.js:14110 Error: Invalid template:'<tr class="k-master-row" data-uid="#=data.uid#" role='row'><td class="#= data && data.dirty && data.dirtyFields && data.dirtyFields['Bill Date'] ? ' k-dirty-cell' : '' #" role='gridcell'>#= data && data.dirty && data.dirtyFields && data.dirtyFields['Bill Date'] ? '<span class="k-dirty"></span>' : '' ##:data.Bill Date==null?'':data.Bill Date#</td><td class="#= data && data.dirty && data.dirtyFields && data.dirtyFields['Bill No.'] ? ' k-dirty-cell' : '' #" role='gridcell'>#= data && data.dirty && data.dirtyFields && data.dirtyFields['Bill No.'] ? '<span class="k-dirty"></span>' : '' ##:data.Bill No.==null?'':data.Bill No.#</td><td class="#= data && data.dirty && data.dirtyFields && data.dirtyFields['Bill Amount'] ? ' k-dirty-cell' : '' #" role='gridcell'>#= data && data.dirty && data.dirtyFields && data.dirtyFields['Bill Amount'] ? '<span class="k-dirty"></span>' : '' ##:data.Bill Amount==null?'':data.Bill Amount#</td></tr>' Generated code:'var $kendoOutput, $kendoHtmlEncode = kendo.htmlEncode;with(data){$kendoOutput='<tr class="k-master-row" data-uid="'+(data.uid)+'" role=\'row\'><td class="'+( data && data.dirty && data.dirtyFields && data.dirtyFields['Bill Date'] ? ' k-dirty-cell' : '' )+'" role=\'gridcell\'>'+( data && data.dirty && data.dirtyFields && data.dirtyFields['Bill Date'] ? '<span class="k-dirty"></span>' : '' )+''+$kendoHtmlEncode(data.Bill Date==null?'':data.Bill Date)+'</td><td class="'+( data && data.dirty && data.dirtyFields && data.dirtyFields['Bill No.'] ? ' k-dirty-cell' : '' )+'" role=\'gridcell\'>'+( data && data.dirty && data.dirtyFields && data.dirtyFields['Bill No.'] ? '<span class="k-dirty"></span>' : '' )+''+$kendoHtmlEncode(data.Bill No.==null?'':data.Bill No.)+'</td><td class="'+( data && data.dirty && data.dirtyFields && data.dirtyFields['Bill Amount'] ? ' k-dirty-cell' : '' )+'" role=\'gridcell\'>'+( data && data.dirty && data.dirtyFields && data.dirtyFields['Bill Amount'] ? '<span class="k-dirty"></span>' : '' )+''+$kendoHtmlEncode(data.Bill Amount==null?'':data.Bill Amount)+'</td></tr>';}return $kendoOutput;'
at Object.compile (kendo.all.min.js:25)
at Object.f [as template] (jquery-2.1.4.min.js:2)
at init._tmpl (kendo.all.min.js:63)
at init._templates (kendo.all.min.js:63)
at init._autoColumns (kendo.all.min.js:64)
at init.refresh (kendo.all.min.js:64)
at init.f (jquery-2.1.4.min.js:2)
at init.trigger (kendo.all.min.js:25)
at init._process (kendo.all.min.js:28)
at init.success (kendo.all.min.js:28)
Georgi Denchev
Telerik team
commented on 23 Jun 2021, 11:01 AM

Hi, Santosh,

Since there is already a ticket opened regarding this problem, let's continue the discussion there.

0
Feyzi
Top achievements
Rank 1
answered on 15 Apr 2015, 06:31 AM
Thank you for your answer. While this fixes the bug it requires some more boilerplate code, but that is possible to handle. Yet still I consider this behavior to be unexpected and I think it should get fixed.

0
Rosen
Telerik team
answered on 16 Apr 2015, 07:10 AM
Hi Feyzi,

I'm afraid that this is how it is design to work. Having spaces in the field name should be explicitly "stated" by using the correct syntax.

On a side note using your suggestion will not work in multiple scenarios - for example if the expression path contains an indexer.

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
Feyzi
Top achievements
Rank 1
Answers by
Feyzi
Top achievements
Rank 1
Rosen
Telerik team
Share this question
or