ColReorder breaks "rollCallBack"
ColReorder breaks "rollCallBack"
bsuk
Posts: 92Questions: 26Answers: 2
I have some code that turns the results of one row into a hyperlink.
However, when I use ColReorder to change the order of the rows, it breaks this.
"rowCallback": function( row, data, index ) {
$('td:eq(1)', row).html('<a href="mypage.php?Serial=' + data.Serial + '">' + data.ComputerName + '</a>' );
},
Is there a way of changing td:eq(1) into something like td:eq(Rowname.Computers) or some equivalent?
In the example documentation:
if ( data.grade == "A" ) {
This only allows me to apply my hyperlinks if I know what the actual row data is.. I was also looking for something like:
if (row.name == "ComputerName) {
Does anyone know of an obvious way to do this?
Many thanks.
This discussion has been closed.
Answers
Okay, I fixed this with a combination of Allan's jsfiddle: http://jsfiddle.net/z8meddv6/1/
and adding a classname: https://datatables.net/reference/option/columns.className
However, reordering the columns also breaks individual column searching (searching brings back results of the old column, rather than the newly located one), and refreshing the page gives strange results: Columns are then returning data from other columns, etc..
Is there an additional step to stop these things happening?
I now have this working by using "render" instead of "callback".
This way, the column settings are respected when moved etc.