Answered by:
Kendo UI and SharePoint Field Names with spaces

Question
-
I am trying to use the Kendo UI grid component with a SharePoint list. The grid is returning some data but seems to be unable to return data from list columns that were created with a space in the column title. SharePoint replaces the space with a "_x0020_" so that something like "Supervisor ID" becomes "Supervisor_x0020_ID". The "Title" column is also not displaying data. Below is an example of my column definition code:
//column def columns: [{ field: "Title", title: "Employee ID"//, //width: 240 }, { template: "<span class='nowrap'>#: Name #</span>", field: "Name", title: "Name", width: 200 }, { field: '["Parent_x0020_ID"]', title: "Supervisor ID" }, { field: "['Parent Name']",//"Parent_x0020_Name", title: "Supervisor Name" }, }]
Monday, June 13, 2016 6:41 PM
Answers
-
Hi,
Please try setting the “url” parameter like this:
“https://yoursite/_vti_bin/ListData.svc/listName”
Then log out the “data” in the done() function to the console of the browser to see if there is “Title” returned.
Per my test, when sending a GET request to the “url” above, I can get the “Title” of an item like this:
console.log(data.d.results[1].Title);
Please let me know if there any progress.
Best regards,
PatrickTechNet Community Support
Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.- Proposed as answer by Patrick_Liang Friday, June 24, 2016 10:11 AM
- Marked as answer by Patrick_Liang Monday, June 27, 2016 10:03 AM
Thursday, June 16, 2016 6:03 AM
All replies
-
Hi,
How API do you use to get data from this SharePoint list? JavaScript Client Object Model or REST API?
For example, if using REST API, the response of list items would be like this:
We can use a code like this to extract the “Supervisor ID” from the response:
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script> <script type="text/javascript"> _spBodyOnLoadFunctionNames.push("ready"); function ready() { $.ajax({ url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('List1')/items", method: "GET", headers: { "Accept": "application/json; odata=verbose" }, success: function (data) { console.log(data.d.results[1].Supervisor_x0020_ID); } }); } </script>
Once you got all the values you need, then you can bind it to the custom grid component.
Best regards,
PatrickTechNet Community Support
Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.Tuesday, June 14, 2016 7:28 AM -
I am trying to do CRUD operations with listdata.svc REST. Here's a snippet for read ops:
var crudServiceBaseUrl = "/_vti_bin/listdata.svc/ListName", Datasource = new kendo.data.DataSource({ type: "odata", transport: { read: function (options) { return $.ajax({ type: "GET", url: kendo.format("{0}?$expand=CreatedBy,ModifiedBy", crudServiceBaseUrl), dataType: "json", data: options.data }).done(function (data, textStatus, jqXHR) { options.success(data); }).fail(function (jqXHR, textStatus, errorThrown) { options.error(jqXHR); }); },
This works with fields whose name does not have any spaces, except for the "Title" field. The "Title" field also does not return results.
Tuesday, June 14, 2016 5:30 PM -
Hi,
Please try setting the “url” parameter like this:
“https://yoursite/_vti_bin/ListData.svc/listName”
Then log out the “data” in the done() function to the console of the browser to see if there is “Title” returned.
Per my test, when sending a GET request to the “url” above, I can get the “Title” of an item like this:
console.log(data.d.results[1].Title);
Please let me know if there any progress.
Best regards,
PatrickTechNet Community Support
Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.- Proposed as answer by Patrick_Liang Friday, June 24, 2016 10:11 AM
- Marked as answer by Patrick_Liang Monday, June 27, 2016 10:03 AM
Thursday, June 16, 2016 6:03 AM