dataTables aoColumnDefs mRender

1

What would be the right way to do this:

var oTable1 = $('#tabela-agenda').dataTable({
    "bProcessing": true,
    "bServerSide": true,
    "sAjaxSource": "cadastroCarregaRegistros.php",
    aoColumnDefs: [
        {
            "aTargets": [ 7 ],
            "bSortable": false,
            "data": 'ID, badge',
            "mRender": function ( data, type, full  ) {
                return  'if ('+badge+' != ""){ "<a class="purple" href="carteirinha.php?badge='+ badge +' " onclick="return hs.htmlExpand(this, {objectType: 'iframe', width: 800, height:400 } )" title="Carteirinha"> <i class="icon-print bigger-130"></i> </a>" }           <a class="blue" href="cadastroPerfil.php?id=' + ID + '&i=2a" title="Perfil"> <i class="icon-zoom-in bigger-130"></i></a>            <a class="green" href="cadastroEditar.php?id=' + ID + '&i=2a" onclick="return hs.htmlExpand(this, {objectType: 'iframe', width: 800, height:400 } )" title="Editar"> <i class="icon-pencil bigger-130"></i> </a>            <a class="red delete-event" href="cadastroApagar.php?id=' + ID + '&foto=foto.jpg&i=2a" title="Apagar" data-title="Apagar" data-content="Deseja apagar esse membro?" onClick="return false;"> <i class="icon-trash bigger-130"></i></a></div>';
            },
            "bSortable": false
        }
    ]
});

Do not load.

ID and badge values are not showing. I used the ligthbox in the html, but in js it looks like something is wrong with 'iframe' .

Thank you all.

    
asked by anonymous 04.12.2014 / 23:26

1 answer

1

Thank you all. Anyone who is experiencing the same problem, see how my solution was.

    {
    "aTargets": [ 7 ],
    "bSortable": false,
    "mData": 0,
    "mData": 1,
    "mData": 2,
    "mRender": function ( data, type, val  ) {
        if (!val[2]){
            return  '<a class="blue" href="cadastroPerfil.php?id=' +  val[0] + '&i=2a" title="Perfil"> <i class="icon-zoom-in bigger-130"></i></a>          <a class="green" href="cadastroEditar.php?id=' + val[0] + '&i=2a" onclick="return hs.htmlExpand(this, {objectType: \'iframe\', width: 800, height:400 } )" title="Editar"> <i class="icon-pencil bigger-130"></i> </a>          <a class="red delete-event" href="cadastroApagar.php?id=' + val[0] + '&foto=' + val[1] + '&i=2a" title="Apagar" data-title="Apagar" data-content="Deseja apagar esse membro?" onClick="return false;"> <i class="icon-trash bigger-130"></i></a></div>'
        }else{
            return  '<a class="purple" href="carteirinha.php?badge=' +  val[2] + ' " onclick="return hs.htmlExpand(this, {objectType: \'iframe\', width: 800, height:400 } )" title="Carteirinha"> <i class="icon-print bigger-130"></i> </a>           <a class="blue" href="cadastroPerfil.php?id=' +  val[0] + '&i=2a" title="Perfil"> <i class="icon-zoom-in bigger-130"></i></a>           <a class="green" href="cadastroEditar.php?id=' + val[0] + '&i=2a" onclick="return hs.htmlExpand(this, {objectType: \'iframe\', width: 800, height:400 } )" title="Editar"> <i class="icon-pencil bigger-130"></i> </a>          <a class="red delete-event" href="cadastroApagar.php?id=' + val[0] + '&foto=' + val[1] + '&i=2a" title="Apagar" data-title="Apagar" data-content="Deseja apagar esse membro?" onClick="return false;"> <i class="icon-trash bigger-130"></i></a></div>'
        }

    },
    "bSortable": false
}                   }
    
05.12.2014 / 01:59