1

When data is returned from a Web API 2.2 OData v4 controller with an OData metadata wrapper, I'm having trouble properly sourcing columns in the enumerated data set in JQuery DataTables. No error, simply "No data available in table" after initialization.

AJAX response:

{
  "odata.metadata":"http://localhost/blahblahblah/$metadata#SearchData","value":[
    {"ShipmentKey":"12345"},
    {"ShipmentKey":"12346"},
    {"ShipmentKey":"12347"},
    {"ShipmentKey":"12348"},
  ],"odata.nextLink":"http://localhost/blahblahblah/SearchData?$skip=100"
}

Datatables column intialiation:

"columns": [
                { "data": "value.ShipmentKey" },
            ]

Also tried:

"columns": [
                    { "data": "value..ShipmentKey" },
                ]

1 Answer 1

1

Ah I see, I needed to use dataSrc to specify "value" in my ajax setup.

$('#blah').dataTable({
    "ajax": {
        "url": 'http://localhost/blahblahblah/SearchData',
        "dataSrc": 'value'
    },
    "columns": [
        { "data": "ShipmentNumber" },
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.