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

Bug with field name with dot or space?

3 Answers 602 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Simon
Top achievements
Rank 1
Simon asked on 10 Jun 2014, 09:15 PM
In this post from Jan 2013, staff said Kendo wasn't handling field names with a dot or a space because it would involve "extra overhead which is not needed in most cases".

This is kind of weird as many SQL statements has to return field with dots.

Two months later, Kendo staff posted a workaround available in Kendo Q1 2013.

I just tried the work around on a grid connected on a remote OData service and I think there's a problem with the getters generated for properties with dots.  Indeed, when I receive data for the grid for a field named 'MyTable.MyField', the following error is raised: "TypeError: Cannot read property 'MyField' of undefined". 

As explained in the solution poster in march 2013, I did set the column field name to "[\"MyTable.MyFieldName\"]".  I was expecting a getter like this one:

return d["MyTable.MyField"];


but after a little investigation, I found that the exception was raised because the getter wasn't generated correctly:

return d.MyTable.MyField;


I've been able to confirm the issue by changing the getter function from

getter: function(expression, safe) {
  return getterCache[expression] = getterCache[expression] || new Function("d", "return " + kendo.expr(expression, safe));
},

to this one (not perfect.... this was to confirm if I was right about the bug)

getter: function(expression, safe) {
  return getterCache[expression] = getterCache[expression] || new Function("d", "return d[\"" + expression + "\"]");
},


Can you please confirm if I'm right about the bug (and if it will be fixed)?

Best regards,

Simon

3 Answers, 1 is accepted

Sort by
0
Simon
Top achievements
Rank 1
answered on 10 Jun 2014, 10:16 PM
Ok...  I think I might have found something.  The brackets formatting has to be set in the in the columns as specified in the workaround but also in the schema.model.fields.
0
Accepted
Alexander Popov
Telerik team
answered on 12 Jun 2014, 12:16 PM
Hi Simor,

Specifying the field's name in the Model is not necessary, however editing this field would cause issues with building the getters as you already noticed. Another approach would be to create a new field and use the from option, as shown in this example.

Regards,
Alexander Popov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Simon
Top achievements
Rank 1
answered on 19 Jun 2014, 11:28 AM
Thank you Alexander.

I didn't know about the "from" property.
Tags
Grid
Asked by
Simon
Top achievements
Rank 1
Answers by
Simon
Top achievements
Rank 1
Alexander Popov
Telerik team
Share this question
or