View Full Version : Need some advice about mysql and grigsorting

21 Apr 2010, 8:07 AM
Hi there!
i need some advice about column types and gridtypes for sorting.
in my mysql database, i have a table type double, where are values like 1.23 till 234.56.

what type of gridcolumn do i need to use, so it wil sort right? (like 1.23 first and 234.56 last).

I also like to ask, if there is any way to make a prefix or a suffix in a gridcolumn wich gets his data from a JSON file. (i want to have the suffix CM in a column)


21 Apr 2010, 10:15 AM
There are only a few basic objects that Javascript understand, and EXT JS as well. I think there is: int,float,string,date,boolean. Check out Ext.data.Field. (http://www.extjs.com/deploy/dev/docs/?class=Ext.data.Field&member=type)

The latter question is more complex, but you would probably have to create your own custom object to do that.
There is file vs. server loading, and the difference is: load vs. loadData. -- In this case, you would probably have to create your own way. The question is vague, so I am guessing at this point.

19 May 2010, 7:19 AM
It's bin a while since i posted, i needed to do some family stuff.
I picked up the scripting again, but i still have some problems with the sorting.

in my DB i have a field with the type double(10,2) i use it to store some heights (in Centimeters).
the column in my grid displays it good (xxx.xx), but the sorting is going wrong..

When i sort for 'biggest first' i get this:
Ans when i sort for 'smalles first' i get this:

see my problem?

I tried to figure it out om the form, faq and api docs, but i still cannot find it.

please help!

greetings from The Netherlands

19 May 2010, 7:29 AM
Did you read my last post? If you didn't specify the field to be numeric, you will be getting that kind of sort problem.

You will need to set the type to float.

How is your JSON looking like?

{rows:[{"myNumber": "99.00"}]}


{rows:[{"myNumber": 99.00}]}

When you are using the store:

fields: [{"name":"myNumber", "type":"float"}]

This is very important. Otherwise your number will be treated like a string, and that's how strings are sorted. The way you have it displayed.

19 May 2010, 8:20 AM
my json is with the quotes ("99.00").

i changed it to this:

var sportprijzen_store = new Ext.data.Store({
url: 'get_them.php?cat=2',
sortInfo: {
field: 'serieprijs',
direction: "ASC"
reader: new Ext.data.JsonReader({
root: 'rows',
id: 'id',
}, [
{"name":"h_a", "type":"float"},
autoLoad: true

but still not working :(

19 May 2010, 9:20 AM
json quoting is irrelevant. The important is the type definition in fields, then the grid will sort correct.

19 May 2010, 10:37 AM
Well, for one thing I would use the property "fields".

There are a series of things to try. Try changing the quotes to unquoted, and also try setting the fields property properly. Who knows what is going on just by setting the array by itself.

If it is quotes, it is all the more relevant to set the type.

Also, I am not too sure which version you are on, but "id" should be "idProperty".

25 May 2010, 10:14 AM
After changing id to idProperty, it will work with float. Next problem: if the number after the dot is 0 (like 22.0) it wil not show (it shows just 22). any way i can fix that?

25 May 2010, 10:20 AM
use a renderer.