Sorting negative numbers

QuestionsSorting negative numbers
Vygandas asked 5 years ago

Hello,

In version 2.6 when sorting DESC,
-5 is higher than 0, which is mathematically false! (0 > -5)
Should be (-5 < 0)

View post on imgur.com

6 Answers
Abu Ghufran Staff answered 5 years ago

Sorting is done by database ORDER BY clause, so make sure your field is numeric in order to sort numerically. If field is varchar, it will sort alphabetically. If it does not solve, please reopen ticket.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Vygandas answered 5 years ago

Nope. The same code, (in this case using “Load Array”).
When using v2.00 lib, works ok! https://imgur.com/a/Wl2U1z8

Column code:

$col = array();
$col[“title”] = “Saldo”; // caption of column
$col[“name”] = “{$row[‘partn_kodas’]}{$row[‘uzs_nr_skaita’]}_saldo”;
$col[“width”] = “70”;
$col[“sorttype”] = int;
$cols[] = $col;

Abu Ghufran Staff answered 5 years ago

I’ve emailed you latest build that is running on this working demo.

https://www.phpgrid.org/demo/demos/loading/load-array.php

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Vygandas answered 5 years ago

Thank You.

Maybe You could add 0 to column quantity in demo ?

and then check again?

Because in my case 0 is higher that negative numbers. And that is incorrect of course.

 

Abu Ghufran Staff answered 5 years ago

I’ve regenerated this issue. will update back.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Abu Ghufran Staff answered 5 years ago

Hello,

Sorting will work with sorttype => number,

$col = array();
$col[“title”] = “Quantity”; // caption of column
$col[“name”] = “quantity”;
$col[“width”] = “100”;
$col[“sorttype”] = “number”;
$cols[] = $col;

Demo: https://www.phpgrid.org/demo/demos/loading/load-array.php

Code: https://www.phpgrid.org/demo/demos/loading/load-array.phps

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Your Answer

7 + 16 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?