Using mRender to show thumbnail image whose path is made from 3 columns data

Using mRender to show thumbnail image whose path is made from 3 columns data

javismilesjavismiles Posts: 205Questions: 38Answers: 3
edited May 2014 in Editor
hi, im trying to use mRender on my table so that
i take the data of 3 columns and with them i build a path to a thumbnail pic that then i show on a new column,

i tried this but didnt work

$('#mtab').dataTable( {
"aaSorting": [[0,'desc']],
"sDom": "Tfprtip",
"sAjaxSource": "php/table.mtab.php",
"aoColumns": [
{
"mData": "id"
},
{
"mRender": function ( param1, param2, param3 ) {
thumb="http://www.domain.com/data/"+param1+"/picture"+param2+param3+".jpg";
return '';}
},

Replies

  • mbayakelvinmbayakelvin Posts: 1Questions: 0Answers: 0
    edited May 2014
    "aoColumns": [
                        {"mData": null,
                            "fnRender": function(oObj) {
                                if (oObj.aData["status"] == 1) {
                      var status = '<img src=""aoColumns": [
                        {"mData": null,
                            "fnRender": function(oObj) {
                                if (oObj.aData["status"] == 1) {
    </pre>
                                    var status = '<img src="<PHP echo YII::app()->request->baseUrl; ?>/img/icons/check.png">';
                                } else if (oObj.aData["status"] == 0) {
                                    var status = '<img src="<PHP echo YII::app()->request->baseUrl; ?>/img/icons/busy.png">';
                                }
                                else if (oObj.aData["status"] == 2) {
                                    var status = '<img src="<PHP echo YII::app()->request->baseUrl; ?>/img/icons/check.png">';
                                }
                                return status;
                            }
                        },/img/icons/check.png">';
                                } else if (oObj.aData["status"] == 0) {
                                    var status = '<img src="<PHP echo YII::app()->request->baseUrl; ?>/img/icons/busy.png">';
                                }
                                else if (oObj.aData["status"] == 2) {
                                    var status = '<img src="<PHP echo YII::app()->request->baseUrl; ?>/img/icons/check.png">'; `
                                }
                                return status;
                            }
                        },
    
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin

    @javismiles - mRender passes in three parameters:

    1. The data for that cell
    2. The data type requested
    3. The data for the whole row

    It doesn't just conveniently pass in the three parameters you want ;-). You need to use the third parameter - something like row.param1, row.param2, etc (assuming you call the third parameter row.

    Allan

This discussion has been closed.