I am trying to get #cccr TBODY TR TD[0] value from my website datatables table. I want user to click on a TR, get the value from a hidden TD in that TR.
I had gridjs.js working, but my DataTables version in much nicer.
I canāt get your code to integrate with the beginning of my DataTables init script. I canāt add a new table spec definition after previously defining and creating the #cccr datatable.
I didnt tell you to replace that. So i am being precise. Youāre introducing words I didnt say.
You have a datatable declaration that begins $('#cccr').DataTable. Catch THAT. Not create a new one, catch āthe tableā (hey look, precise language - singular table.)
Within the outer layer of the ready function, you can then use the variable you created. Because thatās how variable scope works.
So within the ready function, and after youāve created the variable by catching the table, modify that variable to attach an event to it with the .on command.
Iām not going to give you every curly brace and parenthesis here - if you dont understand you need to close everything and define your own function for the on, youāre not at the point that you should be messing with this.
Within the function called by the on, you can use .row(this), which is a method of the table variable, to get a Datatables representation of the row that corresponds to the row that was clicked on.
A Datatables representation of a row has a method, .data(), that yields a numeric array containing all of the data that the table is holding for that row. If the data youāre trying to use isnt part of the Datatables setup for some reason (but it should), this inside the function will be a pointer to the row, and you can use regular jquery methods to extract/modify what you need.