display image using mdata

display image using mdata

carlosavilescarlosaviles Posts: 21Questions: 0Answers: 0
edited March 2013 in General
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]

Replies

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    > mData: [4]

    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
  • carlosavilescarlosaviles Posts: 21Questions: 0Answers: 0
    edited March 2013
    thenks for your respones Allan. What about this? I have tried but doesn´t works

    [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]
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Also looks line. I'd suggest you use mRender , but either should work. If they don't please link to a test case.

    Allan
  • carlosavilescarlosaviles Posts: 21Questions: 0Answers: 0
    edited March 2013
    Thanks Allan. I can´t upload it, but this is my code:

    [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]
  • carlosavilescarlosaviles Posts: 21Questions: 0Answers: 0
    edited March 2013
    Sorry. I haven´t solve it using editor.
  • carlosavilescarlosaviles Posts: 21Questions: 0Answers: 0
    I have solve it! thanks Allan!!

    [code]
    "aoColumns": [
    { "mData": "browser" },
    { "mData": "engine" },
    { "mData": "platform" },
    { "mData": "version", "sClass": "center" },
    { "mData": "grade", "sClass": "center","mRender": function ( data, type, full ) {
    return '';
    } }
    ],
    [/code]
This discussion has been closed.