display image using mdata
display image using mdata
carlosaviles
Posts: 21Questions: 0Answers: 0
Hello. I am trying to display images from my mysql db. I am using this code that I have read in the forum but doesn´t works:
[code] $('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "scripts/server_processing.php",
mData: [4], // id column - string here, could be an integer if you are using plain arrays
mRender: function (d, type, row) {
return ''; // d is the id
}
})[/code]
[code] $('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "scripts/server_processing.php",
mData: [4], // id column - string here, could be an integer if you are using plain arrays
mRender: function (d, type, row) {
return ''; // d is the id
}
})[/code]
This discussion has been closed.
Replies
An array as mData? DataTables doesn't support that. Also mData is a child property of aoColumns or aoColumnDefs. See the documentation: http://datatables.net/usage/columns
Allan
[code]
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
var imgLink = aData['imageLink']; // if your JSON is 3D
// var imgLink = aData[4]; // where 4 is the zero-origin column for 2D
var imgTag = '';
$('td:eq(4)', nRow).html(imgTag); // where 4 is the zero-origin visible column in the HTML
return nRow;
}
[/code]
Allan
[code]
var editor; // use a global for the submit and return data rendering in the examples
$(document).ready(function() {
editor = new $.fn.dataTable.Editor( {
"ajaxUrl": "php/browsers.php",
"domTable": "#example",
"fields": [ {
"label": "Browser:",
"name": "browser",
"className": "allan"
}, {
"label": "Rendering engine:",
"name": "engine"
}, {
"label": "Platform:",
"name": "platform"
}, {
"label": "Version:",
"name": "version"
}, {
"label": "CSS grade:",
"name": "grade"
}
]
} );
dt = $('#example').dataTable( {
"sDom": "Tfrtip",
"sAjaxSource": "php/browsers.php",
"bServerSide": true,
"sServerMethod": 'POST',
"aoColumns": [
{ "mData": "browser" },
{ "mData": "engine" },
{ "mData": "platform" },
{ "mData": "version", "sClass": "center" },
{ "mData": "grade", "sClass": "center" }
],
"oTableTools": {
"sRowSelect": "multi",
"aButtons": [
{ "sExtends": "editor_create", "editor": editor },
{ "sExtends": "editor_edit", "editor": editor },
{ "sExtends": "editor_remove", "editor": editor }
]},
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
var imgLink = aData['grade']; // if your JSON is 3D
// var imgLink = aData[4]; // where 4 is the zero-origin column for 2D
var imgTag = '';
$('td:eq(4)', nRow).html(imgTag); // where 4 is the zero-origin visible column in the HTML
return nRow;
}
} );
} );
[/code]
[code]
"aoColumns": [
{ "mData": "browser" },
{ "mData": "engine" },
{ "mData": "platform" },
{ "mData": "version", "sClass": "center" },
{ "mData": "grade", "sClass": "center","mRender": function ( data, type, full ) {
return '';
} }
],
[/code]