no data loading in table

no data loading in table

dinotomdinotom Posts: 27Questions: 7Answers: 0
edited May 2014 in DataTables 1.10

The following snippet does not load any data to the table even though the url produces data (also shown)

Using Postman here is what the url returns, and array of json objects

[<br />
    {<br />
        "Symbol": null,<br />
        "CompanyInfo": "Flextronics Inc. (FLEX)",<br />
        "id": 0,<br />
        "Date": "2014-05-08T00:00:00-04:00",<br />
        "symbolId": 0,<br />
        "TradeDirection": "Buy",<br />
        "Notes": "Upgraded by Argus, Stock breaking out on weekly chart",<br />
        "WasTradeEntered": null,<br />
        "WasTradeSuccessful": null,<br />
        "EntryPrice": null,<br />
        "ExitPrice": null<br />
    }, {<br />
        "Symbol": null,<br />
        "CompanyInfo": "J.C. Penney (JCP)",<br />
        "id": 0,<br />
        "Date": "2014-05-08T00:00:00-04:00",<br />
        "symbolId": 0,<br />
        "TradeDirection": "Buy",<br />
        "Notes": "Upgraded by UBS analyst who has been negative for over three years.",<br />
        "WasTradeEntered": null,<br />
        "WasTradeSuccessful": null,<br />
        "EntryPrice": null,<br />
        "ExitPrice": null<br />
    }<br />
]

Here is the initializing code I'm using. It's run from a button click.

 ideaTable.DataTable({<br />
            "ajax": {<br />
                "url": "http://localhost:54594/api/Ideas/GetTodaysIdeas",<br />
                "dataSrc": ""<br />
            }<br />
        });<br />

I don't see any data requests hitting Fiddler

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    Hi,

    Related to your other forum post, I'm assuming here that the <br /> tags above are an artefact of how the code has been posted to the forum! If not, then its not valid JSON and that is going to be part of the problem!

    In DataTables, if you are using object based data, you need to tell the table what property to use for each column - since the object itself has no inherent order. This is done using the columns.data option. There is a description of how to do this in the manual, so you would use data: 'Date' for example to get the date for the date column.

    Regards,
    Allan

This discussion has been closed.