add a hyperlink to a table element
add a hyperlink to a table element
mikeddd123
Posts: 6Questions: 0Answers: 0
Firstly thank you allan for this amazing plugin!
I've got this code which seems to be working but I'm not sure if its correct.
I'm trying to add a hyperlink into a cell.
Thanks in Advance!!!
aData[5] - contains the link
aData[3] - contains the text
Here is the sample code:
[code]
$(document).ready(function() {
$('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
/* Append the head to the default row class name */
if ( aData[3] == "Click Me" )
{ /*.....Is this part below correct?.....*/
$('td:eq(2)', nRow).html( 'Click Me' );
}
return nRow;
},
} );
} );
[/code]
I've got this code which seems to be working but I'm not sure if its correct.
I'm trying to add a hyperlink into a cell.
Thanks in Advance!!!
aData[5] - contains the link
aData[3] - contains the text
Here is the sample code:
[code]
$(document).ready(function() {
$('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
/* Append the head to the default row class name */
if ( aData[3] == "Click Me" )
{ /*.....Is this part below correct?.....*/
$('td:eq(2)', nRow).html( 'Click Me' );
}
return nRow;
},
} );
} );
[/code]
This discussion has been closed.
Replies
Allan
As you can see below I'm currently using a local server (wamp).
I'm getting this error when I load the table "DataTables warning: JSON data from server could not be parsed. This is caused by a JSON formatting error.", and when I refresh the table loads normal.
I'm also getting this error in the processing.php file "Notice: Undefined index: sEcho in......" how can I resolve this?
Thanks!
[code]
$(document).ready(function() {
$('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"aoColumns": [
/*id*/ { "bVisible": false},
/*name*/ null,
/*phone#*/ null,
/*click me*/ { "bSortable": false, "fnRender": function ( oObj ) {
return ''+ oObj.aData[3] +'';}, "aTargets": [ 0 ]},
/*date*/ null,
/*hurl*/ { "bVisible": false},
],
"aLengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
"sAjaxSource": "http://localhost/table/processing.php",
"aaSorting": [[0,'desc']],
"aoColumnDefs": [ {
"sClass": "center",
"aTargets": [ -2, -3 ]
} ]
} );
} );
[/code]
Allan