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).
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
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;
}
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
Hi Feyzi,
Having spaces in the field name is only supported if the correct syntax is used in the column declaration. For example:
Regards,
Rosen
Telerik
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
commented on 22 Jun 2021, 05:50 AM
Top achievements
Rank 2
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)
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
commented on 23 Jun 2021, 11:01 AM
Telerik team
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
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
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!