How to return a column's actual value in jQuery datatables

1

I'm feeding my table through ajax and customizing the return. In the status (0 or 1) column I used "fnRender" to return an active or inactive label according to the value, but I need to use this same validation to show the Disable or Enable button and when I get to this step the "fnRender" overwrote the actual value of status to "<span class='label label-success'>Ativo</span>" (or Inactive) and my validation for "mData":"id" that is if(parseInt(oObj.aData['status']) == 1) ends up always falling in the else.

Possible solution

if(oObj.aData['status'] == "<span class='label label-success'>Ativo</span>")

The problem is that I did not want to perform this validation by the string, it seems somehow that this is not right.

Javascript:

var tabela = $('#dynamic-table');

    tabela.dataTable( {
        "aaSorting": [[ 0, "asc" ]],
        "bProcessing": true,
        "bServerSide": true,
        "sAjaxSource": "minhaURL",
        "aoColumns": [{
            "mData":"nome"
          },
          {
            "mData":"status",
            "bSortable": false,
            "fnRender": function (oObj)                              
            {
                var status;
                if(parseInt(oObj.aData['status']) == 1){
                    status = "<span class='label label-success'>Ativo</span>"; 
                }else{
                    status = "<span class='label label-danger'>Inativo</span>";
                }
                return status;
            }
          },
          { 
            "mData":"id",    
            "bSearchable": false,
            "bSortable": false,
            "fnRender": function (oObj)                              
            {
                var btAtivaDesativa;
                btEditar = "<a href='" + oObj.aData['id'] + "' class='btn btn-primary'>Editar</a>";
                if(parseInt(oObj.aData['status']) == 1){
                    btAtivaDesativa = "<a href='" + oObj.aData['id'] + "' class='btn btn-danger'>Desativar</a>"; 
                }else{
                    btAtivaDesativa = "<a href='" + oObj.aData['id'] + "' class='btn btn-success'>Ativar</a>";
                }
                return btEditar + " " + btAtivaDesativa;
            }
           }
        ] 
    } );
    
asked by anonymous 10.04.2014 / 20:01