jQuery DataTables OData connector
jQuery DataTables OData connector
nick_leeson
Posts: 3Questions: 1Answers: 0
First of all, Thanks for creating such an awesome tool.
I am currently using jQuery DataTables OData connector for ODATA v4.
I have a ODATA v4 payload which is in the below format.
{
"@odata.context": "http://services.odata.org/V4/(S(sehqpfh0u431mdbxwr0muwex))/TripPinServiceRW/$metadata#Airports",
"value": [{
"@odata.id": "http://services.odata.org/V4/(S(sehqpfh0u431mdbxwr0muwex))/TripPinServiceRW/Airports('KSFO')",
"@odata.editLink": "http://services.odata.org/V4/(S(sehqpfh0u431mdbxwr0muwex))/TripPinServiceRW/Airports('KSFO')",
"IcaoCode": "KSFO",
"Name": "San Francisco International Airport",
"IataCode": "SFO",
"Location": {
"Address": "South McDonnell Road, San Francisco, CA 94128",
"City": {
"CountryRegion": "United States",
"Name": "San Francisco",
"Region": "California"
},
"Loc": {
"type": "Point",
"coordinates": [-122.374722222222,
37.6188888888889],
"crs": {
"type": "name",
"properties": {
"name": "EPSG:4326"
}
}
}
}
}]
}
My Javascript is like the one below.
$(document).ready( function () {
$('#products1').dataTable({
"sPaginationType": "full_numbers",
"aLengthMenu": [[2, 5, 10, -1], ["Two", "Five", "Ten", "All"]],
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "http://services.odata.org/V4/TripPinServiceRW/Airports?format",
"aoColumns": [
{ "mData": "IcaoCode" },
{ "mData": "Name" },
{ "mData": "IataCode" }
],
"fnServerData": fnServerOData,
"iODataVersion": 4,
"bUseODataViaJSONP": false
})
});
How do I get the values of the Region in my datatable?
This discussion has been closed.
Answers
I don't use the oData conector, but it looks like it should be something like this
Thank you for the reply but no luck on this yet.
The error I am now getting is Requested unknown parameter Location.City.Region from the data source row 0
You'll need to debug that step to see what the data structure is. I generallyl prefer Chrome over IE for that sort of work. It is very easy to see all available objects and use the Watch window to test various syntaxes to get what you need.
Based upon the above example, I would have given exactly the same response as ThomD.
Could you please link to a page showing the issue so we can help to debug it please.
Allan
my complete HTML Page.
I'm afraid we still can't offer any help with that as it does not provide the full information required. As was clearly stated above, please link to the page showing the issue.
Without having a live example I see a couple of things. First, you are using the pre1.10 syntax for dataTables. If you don't have an installed base of DT, I'd move up to current syntax. I looked at the JSON that comes back from that URL and it should work. However, none of the documentation for the plugin shows support for deep objects. It might just be a failing of the oData plug in. I'm using DT with JSON data and not using the plug in, so I'd suggest setting aside the plug in and try without it.
Look at this example.
http://datatables.net/examples/ajax/deep.html