KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Data Table, Filter, Totals not updating #1576

Open Keith Burke opened this topic on on Aug 18, 2020 - 1 comments

Keith Burke commented on Aug 18, 2020

Hi,

I've just noticed that if I enable the search [filter] on a data table, and filter the result set, the total or Col6 doesn't update. Is it possible to do recalculate on filter?

DataTables::create(array(
    "dataStore"=>$this->dataStore('dataset')
    ,"columns"=>array(
        "Col1"=>array(
                "cssStyle"=>"text-align:left;font-weight: bold;color:red;"
                )
        ,"Col2"=>array(
                "cssStyle"=>"text-align:left;font-weight: bold;color:red;"
                )
        ,"Col3"=>array(
                "cssStyle"=>"text-align:center"
                )
        ,"Col4"=>array(
                "cssStyle"=>"text-align:center"
                )
        ,"Col5"=>array(
                "cssStyle"=>"text-align:center"
                )
        ,"Col6"=>array(
                "footer"=>"sum",
                "footerText"=>"<span style='font-size: smaller;font-weight: bold;color:red;'>@value</span>",
                "cssStyle"=>"text-align:center"
                )
        )
    ,"cssClass"=>array(
        "table"=>"table table-hover table-bordered",
        "th"=>"cssHeader",
        "tr"=>"cssItem"
        )
    ,"showFooter"=>"bottom"
    ,"options"=>array(
                "paging"=>true,
                "lengthMenu"=> [ [5, 10, 25, 50, -1], [5, 10, 25, 50, "All"] ],
                "pageLength"=>5,
                "searching"=>true,
                "colReorder"=>true,
                "fixedHeader"=>true,
                "select"=>true,
                "info"=>false,
                "ordering" => true,
                "order"=>array(
                    array(5,"desc"), //Sort by fifth column desc
                    array(0,"asc"), //Sort by first column asc
                    array(1,"asc"), //Sort by second column asc
                    array(2,"asc") //Sort by third column asc
                ),
                "search"=> array(
                    "search"=>"18-24 Female",
                    "caseInsensitive"=>false
                  ),
        )
));
David Winterburn commented on Aug 19, 2020

Hi Keith,

The column's footer setting is computed on server side for the whole table so it's not updated per client filter. To achieve that please try to use a client side footer option:

https://datatables.net/examples/advanced_init/footer_callback.html

To use it with DataTables widget, please put it in options property like this:

DataTables::create(array(
    ...
    "options" => array(
        "footerCallback" => "function() {...}" //put client function in a string quote
    )
));

Let us know if you need further detail. Thanks!

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

DataGrid