Highligh a specific row that has a specific ID attached to its first cell
Highligh a specific row that has a specific ID attached to its first cell
Hi, I've been trying to replicate this behavior what with a different approach. I've got two pages:
* edit.php?id=45 it a form where the record can be modified, and onSubmit it goes to table.php?id=45
* table.php?id= holds a datatable, on which each row has a first hidden column that holds the record unique id. If the id=45 querystring is present, the row that has the row with the 45 id should be highlighted with a classname, but the problem is that I cant seem to find the row through any of the examples.
BTW, I am using a serverside data source, so I can't just use this:
[code]$("#datatable_test tbody tr").find("td:contains("+id+")").addClass("highlight");[/code]
So, I tried the fnGetNodes approach with no luck (http://datatables.net/examples/advanced_init/events_post_init.html):
[code]
var id = <?$_GET['id']?>;
$("tr", datatable_test.fnGetNodes()).each(function(data){
$(this).find("td:contains("+id+")").addClass("highlight");
});
[/code]
Any help will be greatly appreciated!
* edit.php?id=45 it a form where the record can be modified, and onSubmit it goes to table.php?id=45
* table.php?id= holds a datatable, on which each row has a first hidden column that holds the record unique id. If the id=45 querystring is present, the row that has the row with the 45 id should be highlighted with a classname, but the problem is that I cant seem to find the row through any of the examples.
BTW, I am using a serverside data source, so I can't just use this:
[code]$("#datatable_test tbody tr").find("td:contains("+id+")").addClass("highlight");[/code]
So, I tried the fnGetNodes approach with no luck (http://datatables.net/examples/advanced_init/events_post_init.html):
[code]
var id = <?$_GET['id']?>;
$("tr", datatable_test.fnGetNodes()).each(function(data){
$(this).find("td:contains("+id+")").addClass("highlight");
});
[/code]
Any help will be greatly appreciated!
This discussion has been closed.
Replies
[code]
{ "aTargets": [0], "fnCreatedCell": function(nTd, sData, oData, iRow, iCol) {
if(sData == <?=$_GET['id']?>) {
$("#datatable_test tr").eq(iRow).addClass("highlight");
}
}
}
[/code]
Since the data is coming from a Serverside source, there is no datatable_test tr in the DOM. How can I solve this issue? Thanks!
[code]
"fnCreatedCell": function(nTd, sData, oData, iRow, iCol) {
if(sData == <?=$_GET['id']?>){
$.doTimeout("timer_last", 100, function(){
$("#datatable_test tbody tr").eq(iRow).effect("highlight", {}, 1000);
});
}
}
[/code]
Still, it would be cool (and better to implement) to know if there is a way to do it without a timer.