createdRow with leftJoin
createdRow with leftJoin
Tony S
Posts: 26Questions: 4Answers: 0
Hello,
I can not recover the data as soon as I use left join with createdRow, which method should I use ?
$(document).ready(function() {
$('#example').DataTable( {
"createdRow": function ( row, data, index ) {
if ( data[5] < 1 ) {
$('td', row).eq(5).css('background-color', 'red');
}
}
} );
} );
This discussion has been closed.
Answers
You haven't provided enough information to understand the problem.
What happens when using the left join?
What is different between the data when using the left join and not using the left join?
Without being able to see the data and the issue we won't be able to help with suggestions. Please post a link to your page for troubleshooting. If you can't do that then maybe the developers can help by looking at the debug info collected using the debugger.
Kevin
When I use a normal table this function works properly but when I use Table aliases I can not recover the data, it marks me (undefined) in the chrome console.
In this example it's ok :
In this example the answer always undefined :
In this situation how to recover ( data [2] ) ?
I don't use the PHP libraries so I'm not sure exactly what is returned with your left join. This example may help:
https://editor.datatables.net/examples/advanced/joinSelf.html
Based on what you posted it looks like you might have Datatabels configured for arrays but I think you might want to use objects. You can use the browser's developer tools to verify what is in the JSON response.
If this doesn't help then someone more experienced with the PHP libraries will need to help. Or you can post an example of the JSON response.
Kevin
Thank you Kevin, no it does not fit, .I am not strong in javascript, knowing that createdRow does not update after changing the line, is there an automatic refresh function without reloading the page?
Sorry, not clear what you mean.
If you are updating the table data you can use
rowCallback
which will run each time the table is drawn.I'm guessing you are using
ajax
. In this case you can useajax.reload()
to have Datatables refresh the Datatable by fetching the data.Kevin
Ok thank you Kevin