How to get attribute of a cell in DataTable ?
How to get attribute of a cell in DataTable ?
ramnaresh437
Posts: 3Questions: 1Answers: 0
in DataTables
*Below is my test case:
<td class=" text-center">
<a class="score" id ="typ"></a>
</td>
i want like below::::
<td class=" text-center" class="score" id ="typ"> </td>
Answers
Use
cell().node()
to get the cell. Like this:http://live.datatables.net/kufepaja/1/edit
Kevin
Thanks for the response Kevin..
But this is not what I wanted !
I have a dynamic row and table.
In that when I click on empty cell, I wanted the ID to be displayed.
<td class=" text-center" class="score" id ="typ"> </td>
Where do you want it displayed?
You can create a click event handler, like this example and use jQuery to get the
id
of the clicked cell. You can usecell().data()
to update that cell with the id if that is what you are wanting.Please build a simple running test case that show an example of what you have and provide details of what you want so we can offer more specific suggestions.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
My Javascript****************
I do not have the ID of the default element so that i can fetch the data from that attribute id.
my HTML:
my expectation:
*/***************************************
Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide
I would use jQuery to add the id to the
td
in your add_Row function. Maybe something like this:I don't believe there is anything built into Datatables for this. You can use
columns.className
to automatically add classes.Kevin
If the id information is available in the row's data, then use
columns.createdCell
to assign an id (or any other attribute) to the created node.Allan