PDA

View Full Version : Sorting of a Grid column



sravaniv
23 Jan 2012, 11:39 PM
Hi Guys,

I'm facing problem with sorting a particular column of a grid.The column looks like this:30935We should sort the order of appearance of the duty status as 'off-duty','Driving','sleeper'.
I have no clue on how to go about it .
Please help me.

Thanks.

sravaniv
24 Jan 2012, 1:31 AM
popping up the thread
Its urgent.. can you guys please reply if u know :(

Farish
24 Jan 2012, 2:15 AM
If sortable is not set to false on the grid column, you can sort the column by clicking on the column header. However, sorting will depend on the data in the grid i.e. how you render the image in the grid... If its plain text, sorting will work properly.

sravaniv
24 Jan 2012, 2:24 AM
I'm not sure if you understood what I had asked.
All the 'offDuty ' data should appear first followed by 'Driving' data followed by 'sleeper'.
As far as I know ,clicking on the column header would arrange it in ascending or descending order and othing more than that.Isn't it ?

Farish
24 Jan 2012, 3:23 AM
Ok. no I hadnt understood what you had asked for.

I dont know if there is a shortcut to do it but what you can do is to take a temporary array. On the load event of the store, use a for loop to loop over the records and add them to the array in the order you want according to this column. Then use store.loadData() to load that array. This might help you if you need a solution quickly and dont know any other way to do it.

sravaniv
24 Jan 2012, 3:32 AM
But I use JSON for data.

Any other solution ?

Farish
24 Jan 2012, 3:51 AM
You can use Ext.decode() to convert the received JSON string into a javascript object and then do the sorting operations on it.

sravaniv
24 Jan 2012, 5:01 AM
I will try to do that.