Permit dbclick on row
Permit dbclick on row
AnGe7
Posts: 5Questions: 2Answers: 0
Hello all,
I have this code :
$(".list-data-table-search").each(function(){
var columns = [];
var size = $(this).find('th').length;
for(var i = 0; i <= size - 1;i++)
columns.push(null);
$(this).DataTable({
"stateSave":true,
"lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "tout"]],
"pageLength": 10,
"language": {
"url": "/js/dataTableLang.json"
},
"ajax": {
url: $(this).data('url'),
pages: 50
},
"deferRender": true,
"columns": columns
});
});
It permit to have dataTable to each object with "list-data-table-search" class, dynamically.
In PHP response i build my table like this :
$data = array();
$line = [ $col1, $col2, ... ];
$data[] = $line;
Ok, now i would like when i dbclick on TR i'm redirect to one page (data-attribute of TR) if key $line['url-to-redirect'] exists
I don't know how to do this,
someone can help me ?
Thank you
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
nobody can help me ?
Perhaps this example will be useful. Rather than listening for
click
events though, listen fordblclick
.Allan
yeah Allan, that's exactly what i need but how to store my target's url in data[0] (for example) but not display it in table ?
thx !
One option would be to use a hidden column -
columns.visible
.Another would be to have the URL as a
data-*
attribute for the row node, which you can then get withrow().node()
.Allan
nice, i setted data-visible on last <tr> and fix columns configuration like this : (for those who interest)
and after :
Thank you Allan