I'm trying to load a grid with spaces in the datasource field name but there seems to be an error.
I saw that you guys fixed it 3 years ago here but it seems to have been reintroduced.
I couldn't figure out how to link from the Kendo UI Dojo so I copy pasta'd the code here:
5 Answers, 1 is accepted
Sorry, I hit tab and hit submit. Here's the code:
I have examined the sample code and noticed that the columns.field is not defined correctly. Note that in cases where the field name includes space you should use square brackets and quotes to specify the field. Like this:
You can also check a runnable version of the code in the following dojo:
Let me know how it works for you.
The code that you posted works great for displaying!
However, it doesn't seem to be working with inline editing:
Grid 2 seems to work fine because it does not have fields with a space in it but Grid 1:
- Can't load the input when clicking in the cell
- Can't save even if you only edit the normal field
Please have in mind that having a space in the field name is considered bad practice. Such implementation would generate a JSON that has a space in the property names. For more information on the recommended format of JSON property names please refer to the article below:
The approach from my previous post can be used as a workaround in simpler scenarios where the Grid component will display data. However, when editing is also a requirement the approach is not applicable.
With that said, if the database that you are using contains field names with spaces I would suggest specifying a ViewModel that will map these fields to values with no spaces. This way the fields that are sent to the client will not contain spaces.
Thank you for the help.
Have a nice day!