数据表显示0到0的0条目

时间:2016-04-13 12:04:04

标签: javascript jquery datatable datatables

你好我正在使用cakephp和datatables而且我遇到了以下问题:当我在那里放置或设置任何过滤器时,数据表正在过滤我的所有记录,图片失效 Filter with datatable

现在,当我删除数据表代码并只显示表格时,它显示我一切正常 table without datatable

这是代码

<?php 


foreach ($movimientosmon as $mon => $movimientos):?>
    <div class="data-fluid">
        <div class="row-form">
            <hr><?php foreach ($movimientos['listado'] as $a): echo $a['0']['TIPO']; endforeach; ?>
            <h5><b>Moneda: <?php echo $monedas[$mon]; ?> </b></h5>
            <h5> Saldo Incial: <?php echo number_format ($movimientos['inicial'], 2, ',', '.'); ?> </h5>
        </div>
        <div class="row-form">
            <table class="fpTableProvC22<?php echo $mon;?> table" cellpadding="0" cellspacing="0" width="100%">
                <thead>
                    <tr>
                        <th scope='col' width = "8%"><img width="100%" class="logo_imprimir" src="<?php echo $this->webroot; ?>img/logoimp.png" />Fecha</th>
                        <th scope='col' width = "50%">Tipo</th>
                        <th scope='col' width = "8%">N&uacute;mero</th>
                        <th scope='col' width = "8%">Monedas</th>
                        <th scope='col' width = "8%">Debe</th>
                        <th scope='col' width = "8%">Haber</th>
                        <th scope='col' width = "8%">Saldo</th>
                    </tr>
                </thead>
                <thead>
                    <tr>
                        <td><input type="text" name="search_fecha"                         
                        id="date-range" placeholder="Filtrar" class="search_init"></td>
                        <td><input type="text" name="search_tipo" 
                        placeholder="Filtrar" class="search_init"></td>
                        <td><input type="text" name="search_numero" 
                        placeholder="Filtrar" class="search_init"></td>
                        <td><input type="text" name="search_moneda" 
                        placeholder="Filtrar" class="search_init"></td>
                        <td><input type="text" name="search_debe" 
                        placeholder="Filtrar" class="search_init"></td>
                        <td><input type="text" name="search_haber"  
                        placeholder="Filtrar" class="search_init"></td>
                        <td><input type="text" name="search_saldo"  
                        placeholder="Filtrar" class="search_init"></td>
                        </tr>
                </thead>
                <tbody>
                    <?php
                    $k = 0;
                    foreach ($movimientos['listado'] as $a):?>
                        <?php                        
                        if ($k >= $movimientos['fdesde'])
                        {                            
                            echo "<tr>";
                                echo "<td>". implode('/', array_reverse(explode('-',  $a['0']['fecha']))) ."</td>";                             
                                if ($a['0']['TIPO'] > 0)
                                    echo "<td>".$this->Html->link($tipos[$a['0']['TIPO']].$a['0']['ASOCIADO'],array('action' => 'edit/'.$a['0']['id'].'/'.$a['0']['TIPO']),array('target'=>'_blank'))."</td>";
                                else
                                    echo "<td>".$this->Html->link('Recibo', 
                                    array('controller' => 'Cobros', 'action' => 'edit/'.$a['0']['id']),
                                    array('target'=>'_blank'))."</td>";                                                     
                                echo "<td style='text-align: right'>". $a['0']['numero']."</td>";
                                echo "<td>". $monedas[$a['0']['moneda_id']]."</td>";
                                echo "<td style='text-align: right'>". number_format ( $a['0']['DEBE'], 2, ',', '.')."</td>";
                                if ($a['0']['HABER']==0)
                                    $stylo = "";
                                else
                                    $stylo = "color: #08c;font-weight:bold;";
                                echo "<td style='text-align: right; ".$stylo."'>". number_format ( $a['0']['HABER'], 2, ',', '.')."</td>";
                                echo "<td style='text-align: right'>". number_format ( $a['0']['SALDO'], 2, ',', '.')."<td>";
                            echo '</tr>';
                        }
                        $k++;
                    endforeach;
                    ?>
                    </tbody>
            </table>
        </div>

        <div class="row-form">
            <h5> Saldo Final: <?php echo number_format ($movimientos['final'], 2, ',', '.'); ?> </h5>
        </div>
    </div>
<?php endforeach;?>

<script>    
    columnas_sort = [{ "sType": "date-uk" }, null, null, null, null, null, null];
    $(document).ready(function(){
        var TablaDatoab = null;
        var TablaDatoab2 = null;                                
        $(".logo_imprimir").hide();
        if($('.fpTableProvC221').length>0 || $('.fpTableProvC222').length>0){
            console.log('esta generando un datatable 221');
                TablaDatoab = $('.fpTableProvC221').dataTable({
            bSort: true,                                                    
            bAutoWidth: true,   
            "iDisplayLength": 25, "aLengthMenu": [25, 50, 100], // can be removed for basic 10 items per page
            "sPaginationType": "full_numbers",
            "sDom": 'T<"clear">lfrtip',  
            //"order": [[ 0, 'asc' ]],          
            "oTableTools": {
                "sSwfPath": "/akesse/js/plugins/datatables/swf/copy_csv_xls_pdf.swf",
                "aButtons": [                
                     {
                    "sExtends":    "collection",
                    "sButtonText": "Exportar",
                    "aButtons":    [ "csv", "xls", "pdf" ],
                    "fnClick": function( nButton, oConfig ) {
                     $(".logo_imprimir").show();    
                        this._fnCollectionShow(nButton, oConfig);
                        }
                    }                  
                ]
            },
            "aoColumns": columnas_sort,
            "aoColumnDefs": [{ "bSortable": true, "aTargets": [] }],
            "aaSorting": [[0,'asc']]                                                                                            
            });

             TablaDatoab2 = $('.fpTableProvC222').dataTable(
                                    {bSort: true,                                                   
            bAutoWidth: true,   
            "iDisplayLength": 25, "aLengthMenu": [25, 50, 100], // can be removed for basic 10 items per page
            "sPaginationType": "full_numbers",
            "sDom": 'T<"clear">lfrtip',                      
            "oTableTools": {
                "sSwfPath": "/akesse/js/plugins/datatables/swf/copy_csv_xls_pdf.swf",
                "aButtons": [                
                     {
                    "sExtends":    "collection",
                    "sButtonText": "Exportar",
                    "aButtons":    [ "csv", "xls", "pdf" ],
                    "fnClick": function( nButton, oConfig ) {
                     $(".logo_imprimir").show();    
            this._fnCollectionShow(nButton, oConfig);
        }
                }

                ]
            },
                                     "aoColumns": columnas_sort,
            "aoColumnDefs": [{ "bSortable": true, "aTargets": [] }
                            ],
                                     "aaSorting": [[0,'asc']]



                                }        
                                    );                                          

        $("thead input").keyup(function () {
            TablaDatoab.fnFilter(HtmlEncode(this.value), $("thead input").index(this));
            TablaDatoab2.fnFilter(HtmlEncode(this.value), $("thead input").index(this));
        });


        $("thead input").each(function (i) {
            if (this.value != "") {

                TablaDatoab.fnFilter(HtmlEncode(this.value), $("thead input").index(this));
                TablaDatoab2.fnFilter(HtmlEncode(this.value), $("thead input").index(this));
            }
        });


        $("thead input").focus(function () {
            if (this.className == "search_init")
            {
                this.className = "";
            }
        });

        $("thead input").blur(function (i) {
            if (this.value == "")
            {
                this.className = "search_init";
            }
        });

 /* $('#fecha_d').on('change',function(){
      TablaDato.fnDraw();
      TablaDato2.fnDraw();


  });
  $('#fecha_h').on('change',function(){
      TablaDato.fnDraw();
      TablaDato2.fnDraw();


  });


  $('#moneda_tipo').on('change',function(){
      TablaDato.fnDraw();         
      TablaDato2.fnDraw();
  });*/
/*      
   $.fn.dataTableExt.afnFiltering.push(
                function (oSettings, aData, iDataIndex) {
                    // "date-range" is the id for my input
                    var desdee = $('#fecha_d').attr("value");
                    var hastaa = $('#fecha_h').attr("value");
                    var moneda_t=$('#moneda_tipo').find(":selected").text();
                                        //console.log(moneda_t); 
                    // parse the range from a single field into min and max, remove " - "
                    dateMin = desdee.substring(6, 10) + desdee.substring(3, 5) + desdee.substring(0, 2);
                    dateMax = hastaa.substring(6, 10) + hastaa.substring(3, 5) + hastaa.substring(0, 2);

                    // 4 here is the column where my dates are.
                    var date = aData[0];
                    var coinn = aData[3];

                    //date = date.substring(0,10);
                    date = date.substring(6, 10) + date.substring(3, 5) + date.substring(0, 2)
                    if(moneda_t == "Todas"){

                    console.log('la fecha ' + date);
                    // run through cases
                    if (dateMin == "" && date <= dateMax) {
                        return true;
                    }
                    else if (dateMin <= date && "" == dateMax) {
                        return true;
                    }
                    else if (dateMin <= date && date <= dateMax) {
                        return true;
                    }

                    }
                    else{
                                                     if(coinn.length == moneda_t.length){


                        if (dateMin == "" && date <= dateMax ) {                                                         
                        return true;
                    }                    
                    else if (dateMin <= date && "" == dateMax ) {
                        return true;
                    }
                    else if (dateMin <= date && date <= dateMax ) {
                        return true;
                    }
                                        }
                    }
                    // all failed
                    return false;
                }
        );
*/
  /*      $('#botonMC223').click();



                             $('#botonMC223').click(function () {
                        console.log('inicializa el filtro');
            TablaDato.fnDraw();
            TablaDato2.fnDraw();
        });*/                           

                            }   

                            });


                            </script>

我已经尝试删除第二个表并且没有任何反应,它看起来是对我无法看到的过滤器的调用(sinfo表示从5条记录中过滤显示0到0的0) 任何帮助,建议,将受到高度赞赏,提前感谢!

0 个答案:

没有答案