table.row(this).data() returnes Undefined (at first)
table.row(this).data() returnes Undefined (at first)
I'm following the example on the row().data() page for how to get the row data into the console. This worked for me before in my project, but now when I try to do this, the browser console at first shows Undefined, and then within a split second it displays the row data.
I'm trying to get the 'id' field value in order to open a details popup, but it fails as the 'id' is undefined at first and so the popup call fails.
What would cause this to return Undefined at first but then almost immediately after, return the actual row data?
Thanks
Sean
Answers
Sounds like you might be Ajax loading the data? It's hard to say without seeing a test case showing the issue.
Allan
I am using Ajax to load the table data using serverside processing. Is there something I need to do in the Ajax call to help this?
Sean
When you say you are following the example on the
row().data()
page are you referring to this?Are you doing anything else in the event handler? It sounds like you might have an asynchronous process in the event handler.
The above code works with server side processing, for example:
https://live.datatables.net/qoliyehi/43/edit
As Allan said we will need a running test case to help debug the issue.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
I just put a check in the event handler to see if the row was undefined or not. If not, it would call my secondary function. A bit of a hack but it seems to work.
Sean