Get raw data inside a cell

Get raw data inside a cell

barlebybarleby Posts: 10Questions: 3Answers: 0

Simple question: on clicking the Check marks on several rows, I get the rows data via:
myIds = dt.rows({selected: true}).data();

However, in my HTML one column contains text WRAPPED inside a component like this:
<td>
<INDICATOR class= "ok_status>
OK status
</INDICATOR>

When I get the data, the content for that column is the complete HTML: <INDICATOR class="ok_status">OK status</INDICATOR>, but I need to get only the text inside: OK_status
How can I possibly do that?
The reason of needeing just the text is that I'm creating a javascript object with key/values where the value is the content (no need of the wrapping html tags)

Replies

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • kthorngrenkthorngren Posts: 21,171Questions: 26Answers: 4,922

    I would loop through the rows using rows().every() then use jQuery to get the text of the <INDICATOR>. Something like this:
    http://live.datatables.net/rociquji/1/edit

    You will still need the {selected: true} - I was too lazy to setup the select part :smile:

    Kevin

This discussion has been closed.