Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 81996

Column Sum Not working ?

$
0
0

Hi I want to do sum of some column of my table the code is note working.
Please help me to find out what is wrong in my code.
this is example link

here is my js

<script type="text/javascript">

 $(document).ready( function () {
// Setup - add a text input to each footer cell
$('#ContentPlaceHolder1_GridView1 thead tr').clone(true).appendTo( '#ContentPlaceHolder1_GridView1 thead' );
$('#ContentPlaceHolder1_GridView1 thead tr:eq(1) th').each( function (i) {
    var title = $(this).text();
    $(this).html( '<input type="text" placeholder="Search '+title+'" />' );

    $( 'input', this ).on( 'keyup change', function () {
        if ( table.column(i).search() !== this.value ) {
            table
                .column(i)
                .search( this.value )
                .draw();
        }
    } );
} );

     var table = $('#ContentPlaceHolder1_GridView1').DataTable({   
            dom: 'Bfrtip',
            buttons: [
                 {
                     extend: 'print',
                     title: '',
                     customize: function ( win ) {
                         $(win.document.body)
                             .css( 'font-size', '10pt' )
                             .prepend( document.getElementById('ContentPlaceHolder1_lblCompanyNameHeader').innerText +
                                 '<div>Freight Contract Register   </div><img src="http://datatables.net/media/images/logo-fade.png" style="position:absolute; top:0; left:0;" />'
                             );

                         $(win.document.body).find( 'table' )
                             .addClass( 'compact' )
                             .css( 'font-size', 'inherit' );
                     }
                 },


        'excelHtml5',
        'csvHtml5',
        'pdfHtml5'
            ],

            "paging": false,
            "orderCellsTop": true,

     });

         var sum = $('#ContentPlaceHolder1_GridView1').DataTable().column(12).data().sum();
         $($('#ContentPlaceHolder1_lblError')).html(sum);

     $('#ContentPlaceHolder1_GridView1').DataTable({
         drawCallback: function () {
             var api = this.api();
             $(api.table().footer()).html(
               api.column(12, { page: 'current' }).data().sum()
             );
         }
     });


 });


</script>

Viewing all articles
Browse latest Browse all 81996

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>