Access Jquery "data" parameter of the row inside render function
Access Jquery "data" parameter of the row inside render function
sergeda
Posts: 42Questions: 16Answers: 0
I'm trying to get Jquery "data" parameter of the row inside render function for the column. Is this possible?
This discussion has been closed.
Replies
The
columns.render
function parameters arefunction render( data, type, row, meta )
. As mentioned in the doc thedata
parameter is the data for the cell.I'm not sure I understand what you mean by
Jquery "data" parameter
. Can you provide more details of what you want to do?Kevin
I have the following snippit in my code under the 'columns' section:
You can see the entire thing in action here: http://www.pikespeakmarathon.org/results/ppa/2017/
Note that all of the data for the table is sourced by a javascript / json data object. It is not dom driven.
For the render function, we have three parameters: data, type, row. (I have no idea what 'meta' is for and just ignore it.) The first parameter, 'data' is the data entry for the cell (the "full_name" attribute), 'type' is the type ("sort", "filter," etc), and 'row' is the data structure for the entire row.
There are a few things going on here:
If I need to return data for a sort, I just return the cell value
If I need to return data for a filter, I return the full_name_filter data (this contains both us-ascii and utf-8 values for ease in searching)
If anything else (like the display) I want to display the fa-trophy icon in front of participants who are award winners. I have a "award_winner" attribute for the row that tracks this. So if that attribute is set to yes, I return the icon with the full_name attribute. Otherwise I just return the full_name attribute.
I hope this helps.
--john
To clarify my question.
I have rows in the table specified like this:
<tr data-recordType="mytype"><td>id</td><td>other value</td></tr>
and then inside render function for column with id I want to get recordType for current row. Is this possible?
You can access it using
createdRow
. For example:Kevin
Thanks Kevin