Altering a responsive table value in the mobile experience
Altering a responsive table value in the mobile experience
![northcutt](https://secure.gravatar.com/avatar/5b0c4ba15807a11edaf2183e7cc6da42/?default=https%3A%2F%2Fvanillicon.com%2F5b0c4ba15807a11edaf2183e7cc6da42_200.png&rating=g&size=120)
Link to test case: https://roi.fyi/crypto/
Debugger code (debug.datatables.net): no errors to debug
Error messages shown: no error
Description of problem:
Hi all,
I've got a table that's working like a dream, save for one issue.
When I try to run computations on a column of results and put them back using jQuery... it works! Right up until you collapse the responsive experience. It appears that the collapsed responsive cell stores data in a value named SPAN (dtr-data) beneath a LI and I'm not sure how to access it.
Is there possibly an API call or workaround for changing these cell values (after they go responsive) using some means other than locating it on the DOM and replacing? Because I'm not seeing a way to do that that's responsive-friendly.
Cheers.
This question has an accepted answers - jump to answer
Answers
You have a lot of code to look through. Maybe you can point out the code doing the calculations. My guess is you need to use something like
column().data()
to get the data instead of the methods you are currently using. Take a look at this example.Kevin
Thanks for the quick response, I'll give that call a look!
This is the function that does the updating.
It is best to use one of the Datatables
data()
API's (row().data()
,cell().data()
orcolumn().data()
) to get the table data instead of relying on jQuery or Javascript methods. Only the table data displayed on the page is in the DOM. The rest is accessible via Datatables APIs. You can also use thenode()
APIs if you need the element instead of the data. See the API docs for more details.Kevin
Very helpful, thank you!