KoolReport's Forum

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

Column sorting problem datagrid #2104

Closed Damien Monk opened this topic on on May 26, 2021 - 3 comments

Damien Monk commented on May 26, 2021

latest version of koolreports 5.0.4

I am having the following sorting problems using dataGrid

this does not change if I set my column type to number, text, string or no type and I have no additional sorting configured.

number only in column

100
1000
1100
1200
1300
200

number before text and spacing between them

100 some street
10000 some street
1001 some street
200 some street

column with letter in front the number no spacing

M1
M10
M11
M12
M5
M6

I am using the default setting that came with the koolreports download and are used to generate the example reports.

Alphabetically it sorts fine, this is only happening with numbers.

<?php
DataTables::create(array(
    "dataSource"=>$this->dataStore("alpha_report"),
    "showFooter"=>true,
    "cssClass"=>array(
        "table"=>"table table-striped table-bordered",
        "tr"=>"cssItem",
        // Column Data Position
        "td"=>function($row,$colName)
        {
            if ($colName=="HI")
            {
                return "text-right";
            }
        },
        "th"=>function($colName) {
            return $colName;
        },
        //Header Data Position
        "th"=>function($colName)
        {
            if (in_array($colName,array("Name")))
            {
                return "text-center";
            }
        },
    ),
    "plugins"=>["Buttons"], //KeyTable SearchPanes
    "fastRender"=>true,
    "options"=>array(
        "dom"=>'Bfrtip',
        "buttons"=>["csv", "pdf", "print"],
        "searching"=>true,
        "colReorder"=>true,
        "fixedHeader"=>true,
        "select"=>true,
        "autoWidth"=>false,
    ),
    "columns"=>array(
        "Name",
        "Address"=>array(
            "label"=>"Address",
            "type"=>"string"
        ),
        "Acc"=>array(
            "label"=>"Acc",
            "type"=>"text",
        ),
        "Made",
        "Af-Tm"=>array(
            "label"=>"Af/Tm",
            "type"=>"string"
        ),
        "HI"=>array(
        ),
        "Balance"=>array(
            "label"=>"Balance",
            "type"=>"currency",
            "footer"=>"sum",
            "decimals"=>2,
            "decimalPoint" => ".",
            "thousandSeparator" => "",
        ),
        "Trm",
        "PastDue",
        "RenewHI"=>array(
            "label"=>"RenewHI",
            "type"=>"text",
        ),
        "NetProc",
        "Work",
    ),
));

Sebastian Morales commented on May 27, 2021

Damien, pls consult these topics to see if their solutions can help in your case:

DataGrid not sorting numerics

Datatables - sorting by date

Let us know if you have any question. Tks,

Damien Monk commented on May 27, 2021

ok thank you for the links, I didnt see those so I will try them

Damien Monk commented on May 27, 2021

Thank you so much!!!! The first link did it! What an awesome product!!!

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
solved

DataGrid