Welcome Guest, Not a member yet? Register   Sign In
Problem with DataTables CodeIgniter And IE 8
#1

[eluser]pmsfo[/eluser]
Hi to all, i having i small problem with datatables and CI, and i don't know i to solve it.

The problem is:

I am using Datatables http://www.datatables.net/ with CI. I am using Data Tables Ajax source pagination.

In firefox the pagination works like i charm but in IE the grid appear always the message processing.

I am posting the code so someone can help me , and see what i did, maybe his i nice example for datatables with codeigniter.

The Code:

The View :
Code:
[removed]

$(document).ready(function() {

var numeroProjecto;
var oTable;

TableToolsInit.sSwfPath = "swf/ZeroClipboard.swf";
oTable = $('#gridPesquisar').dataTable({
        "bJQueryUI": false,
    "sPaginationType": "full_numbers",
        "oLanguage": {"sUrl": "css/jquery/tabletools-pt.txt"},
        "bStateSave": false, // Grava o estado da Table
        "bLengthChange": true,
    "bFilter": true,
        "iDisplayLength": 10,
    "bSort": true,
    "bInfo": true,
    "bAutoWidth": false,
        "bProcessing": true,
        "bServerSide": true,
        "sDom": 'T<"clear">frtip',
        "aoColumns": [            { "sName": "NÂș" },
                                        { "sName": "Beneficiario" },
                                        { "sName": "Contribuinte" },
                                        { "sName": "Distrito" },
                                        { "sName": "Concelho" },
                                       // { "sName": "Data Candidatura" },
                                        { "sName": "Medida" },
                                        { "sName": "Aviso" },
                    ],

      
       "sAjaxSource": "&lt;?php echo $base_url ?&gt;/index.php/pedidoapoio/paginatePedidoApoio",

        "fnServerData": function ( sSource, aoData, fnCallback ) {
                //REQUIRED: Add a Post variable with the object value
                aoData.push( { "name": "object", "value": "browser" } );
                aoData.push( { "name": "txtNumeroProjectoInicial", "value": document.forms[0].txtNumeroProjectoInicial.value });
                aoData.push( { "name": "txtNumeroProjectoFinal", "value": document.forms[0].txtNumeroProjectoFinal.value });
                aoData.push( { "name": "txtNif", "value": document.forms[0].txtNif.value });
                aoData.push( { "name": "txtBeneficiario", "value": document.forms[0].txtBeneficiario.value });
                aoData.push( { "name": "cmbConcelho", "value": document.forms[0].cmbConcelho.value });
                aoData.push( { "name": "cmbDistrito", "value": document.forms[0].cmbDistrito.value });
                aoData.push( { "name": "cmbMedida", "value": document.forms[0].cmbMedida.value });
                aoData.push( { "name": "cmbAviso", "value": document.forms[0].cmbAviso.value });
                aoData.push( { "name": "cmbParecer", "value": document.forms[0].cmbParecer.value });
                aoData.push( { "name": "txtDataCandidaturaInicial", "value": document.forms[0].txtDataCandidaturaInicial.value });
                aoData.push( { "name": "txtDataCandidaturaFinal", "value": document.forms[0].txtDataCandidaturaFinal.value });
                
                $.ajax( {
                        dataType: 'json',
                        type: "POST",
                        url: sSource,
                        data: aoData ,
                        success: fnCallback
                } );
        },
        
         "fnDrawCallback": function( oSettings ) {
                $('#gridPesquisar tbody tr').click( function() {
        var iPos = oTable.fnGetPosition( this );
                var idPedidoApoio = oSettings.aoData[iPos]._aData[0];
                if(navigator.appName == "Netscape") [removed].href = "index.php/pedidoapoio/candidatura/" + idPedidoApoio;
                if(navigator.appName == "Microsoft Internet Explorer") [removed].href = "pedidoapoio/candidatura/" + idPedidoApoio;
                } );
            }
    });


// first slide down and blink the message box
$("#flashmessage").animate({top: "0px"}, 1000 ).show('fast').fadeIn(300).fadeOut(2000);


} );
});
[removed]

<table id="gridPesquisar" cellpadding="1" cellspacing="2" border="0" style="width:100%"></table>
#2

[eluser]pmsfo[/eluser]
THE CONTROLLER

Code:
function paginatePedidoApoio()
    {
        /* Paging */
    $sLimit = "";
    if ( isset( $_POST['iDisplayStart'] ) )
    {
            $this->db->limit(mysql_real_escape_string( $_POST['iDisplayLength'] ),
                             mysql_real_escape_string( $_POST['iDisplayStart'] ));
    }

        /* Ordering */
    if ( isset( $_POST['iSortCol_0'] ) )
    {
        $sOrder = "";
        for ( $i=0 ; $i<($_POST['iSortingCols'] ) ; $i++ )
        {
            $sOrder .= $this->fnColumnToField(($_POST['iSortCol_'.$i] ))."
                 ".( $_POST['sSortDir_'.$i] ) .", ";
        }

        $sOrder = substr_replace( $sOrder, "", -2 );
                $this->db->order_by("idPedidoApoio");
    }


        /* Filtering - NOTE this does not match the built-in DataTables filtering which does it
     * word by word on any field. It's possible to do here, but concerned about efficiency
     * on very large tables, and MySQL's regex functionality is very limited
     */
    $sWhere = "";
    if ( $_POST['sSearch'] != "" )
    {
            $this->db->or_like('pap_PedidoApoio.idPedidoApoio', mysql_real_escape_string( $_POST['sSearch'] ));
            $this->db->or_like('bnf_Beneficiario.Nome', mysql_real_escape_string( $_POST['sSearch'] ));
            $this->db->or_like('bnf_Beneficiario.NIF', mysql_real_escape_string( $_POST['sSearch'] ));

            $this->db->or_like('btl_Distrito.Nome', mysql_real_escape_string( $_POST['sSearch'] ));

            $this->db->or_like('btl_Concelho.Nome', mysql_real_escape_string( $_POST['sSearch'] ));
            $this->db->or_like('prd_Medida.idMedida', mysql_real_escape_string( $_POST['sSearch'] ));
            $this->db->or_like('prd_Aviso.Descricao', mysql_real_escape_string( $_POST['sSearch'] ));
    
    }
        // Valores do Formulario
        if ( $_POST['txtNumeroProjectoInicial'] != "") { $this->db->where('pap_PedidoApoio.idPedidoApoio >=', $_POST['txtNumeroProjectoInicial']);}
        if ( $_POST['txtNumeroProjectoFinal'] != "" ) { $this->db->where('pap_PedidoApoio.idPedidoApoio <=', $_POST['txtNumeroProjectoFinal']);}
        if ( $_POST['txtNif'] != "" ) { $this->db->where('bnf_Beneficiario.NIF =', $_POST['txtNif']);}
        if ( $_POST['txtBeneficiario'] != "" ) { $this->db->where('bnf_Beneficiario.Nome ', $_POST['txtBeneficiario']);}

        if ( $_POST['cmbDistrito'] != "" && $_POST['cmbDistrito'] != "0") { $this->db->where('pap_PedidoApoio.idDistrito = ', $_POST['cmbDistrito']);}

        if ( $_POST['cmbConcelho'] != "" && $_POST['cmbConcelho'] != "0") { $this->db->where('pap_PedidoApoio.idConcelho = ', $_POST['cmbConcelho']);}
        if ( $_POST['cmbMedida']   != "" && $_POST['cmbMedida'] != "0") { $this->db->where('prd_Medida.idMedida = ', $_POST['cmbMedida']);}
        if ( $_POST['cmbAviso'] != ""    && $_POST['cmbAviso'] != "0" ) { $this->db->or_where('prd_Aviso.idAviso = ', $_POST['cmbAviso']);}
        if ( $_POST['cmbParecer'] != ""  && $_POST['cmbParecer'] != "0" ) { $this->db->or_where('prd_Aviso.idAviso = ', $_POST['cmbParecer']);}

        //if ( $_POST['txtDataCandidaturaInicial'] != "" ) { $this->db->where('pap_PedidoApoio.DataCriacao AS DataCandidaturaInicial >=', $_POST['txtDataCandidaturaInicial']);}
        //if ( $_POST['txtDataCandidaturaFinal'] != "" ) { $this->db->where('pap_PedidoApoio.DataCriacao AS DataCandidaturaFinal <=', $_POST['txtDataCandidaturaFinal']);}
#3

[eluser]pmsfo[/eluser]
Controller Continued

Code:
$this->db->select('
               pap_PedidoApoio.idPedidoApoio AS idPedidoApoio,
               bnf_Beneficiario.Nome AS Beneficiario,
               bnf_Beneficiario.NIF AS Contribuinte,
               btl_Distrito.Nome AS Distrito,
               btl_Concelho.Nome AS Concelho,
               pap_PedidoApoio.DataCriacao AS DataCandidatura,
               prd_Medida.Descricao AS Medida,
               prd_Aviso.Descricao AS Aviso
     ');


     $this->db->from('pap_PedidoApoio pap_PedidoApoio');
    
     $this->db->join('bnf_Beneficiario bnf_Beneficiario','pap_PedidoApoio.IDBeneficiario =bnf_Beneficiario.IDBeneficiario');
     $this->db->join('prd_AvisoComponente prd_AvisoComponente','pap_PedidoApoio.idAvisoComponente=prd_AvisoComponente.idAvisoComponente');
     $this->db->join('prd_Aviso prd_Aviso','prd_AvisoComponente.idAviso = prd_Aviso.idAviso');


     $this->db->join('prd_Medida prd_Medida','prd_AvisoComponente.idMedida = prd_Medida.idMedida');
  
    
    // $this->db->ar_join[] = 'INNER JOIN pap_PedidoApoio pap_PedidoApoio ON (pap_PedidoApoio.idConcelho = btl_Concelho.idConcelho AND pap_PedidoApoio.idDistrito = btl_Distrito.idDistrito)';


  $this->db->join('btl_Concelho btl_Concelho','pap_PedidoApoio.idConcelho = btl_Concelho.idConcelho');
    $this->db->join('btl_Distrito btl_Distrito','pap_PedidoApoio.idDistrito = btl_Distrito.idDistrito');

     $this->db->group_by('pap_PedidoApoio.idPedidoApoio');

     $rResult= $this->db->get();


     $iFilteredTotal = $this->db->count_all('pap_PedidoApoio');
      
     $aResultTotal = $this->db->count_all('pap_PedidoApoio');
     $iTotal = $this->db->count_all('pap_PedidoApoio');

    

        $sOutput = '{';
    $sOutput .= '"sEcho": '.intval($_POST['sEcho']).', ';
    $sOutput .= '"iTotalRecords": '.$iTotal.', ';
    $sOutput .= '"iTotalDisplayRecords": '.$iFilteredTotal.', ';
    $sOutput .= '"aaData": [ ';

    
        foreach ($rResult->result_array() as $aRow)
        {
            $sOutput .= "[";

        $sOutput .= '"'.addslashes($aRow['idPedidoApoio']).'",';
        $sOutput .= '"'.addslashes($aRow['Beneficiario']).'",';
        $sOutput .= '"'.addslashes($aRow['Contribuinte']).'",';
                $sOutput .= '"'.addslashes($aRow['Distrito']).'",';
                $sOutput .= '"'.addslashes($aRow['Concelho']).'",';
                //$sOutput .= '"'.addslashes($aRow['DataCandidatura']).'",';
        $sOutput .= '"'.addslashes($aRow['Medida']).'",';
        $sOutput .= '"'.addslashes($aRow['Aviso']).'",';
                
        $sOutput .= "],";
        }

    $sOutput = substr_replace( $sOutput, "", -1 );
    $sOutput .= '] }';
        
        echo $sOutput;
#4

[eluser]pmsfo[/eluser]
Please can you help me! This problem is driving-me nuts.

Best Regards, and thank to all.
#5

[eluser]pmsfo[/eluser]
I resolved the problem it was my json was not very well econded.

http://www.newitperson.com/




Theme © iAndrew 2016 - Forum software by © MyBB