PDA

View Full Version : [CLOSED] Custom GridPanel Sorting



softmachine2011
Jun 07, 2013, 9:56 AM
Hi,

I have a grid with N columns, and only one of these is sortable. I want to perform a custom order when user order this column.

When I say custom order, it means that sortable column is field "X" and in my sort function I want to to use columns "Y and "Z" that are fields of model, but not visible columns for example.

Is there a way to perform this?

I'm using Ext.NET 2.1 r4377 (ExtJS 4.1.3)

Daniil
Jun 07, 2013, 12:35 PM
Hi @softmachine2011,

It should be possible via remote sorting. To enable it please set up RemoteSort="true" for a Store.

softmachine2011
Jun 07, 2013, 12:45 PM
Hi @softmachine2011,

It should be possible via remote sorting. To enable it please set up RemoteSort="true" for a Store.

Yes I know, I forget to tell you that this rows are generated in client side, then sort must be performed in client side.
I was investigating and I found that you can create something like this in store model



<ext:ModelField Name="MyField" Type="Int" UseNull="true">
<CustomSortType Fn="MyCutomSortTypeFn" />
</ext:ModelField>


Is this what I'm looking for? If yes, how it is used?
I see that, only column value is received by sorter function...

Daniil
Jun 07, 2013, 4:17 PM
Here is an example for Ext.NET v1.
http://forums.ext.net/showthread.php?12152#post49619

I think it should be similar in Ext.NET v2 (but, probably, not exactly the same).

Hope this helps.

softmachine2011
Jun 10, 2013, 6:39 AM
Like I say in previous post, CustomSortType only pass column value as argument and I need another column value to define order.
I think that CustomSortType isn't what I'm looking for, is there another way to do it?

Daniil
Jun 10, 2013, 11:33 AM
Yes, you are right, there is only a value available.

I think you should implement custom sorting by switching off default sorting. Then catch a header click (a ColumnModel's HeaderClick event) and sort the data by calling a Store's sort method, passing custom sorters.
http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.data.Store-method-sort

Hope this helps.

softmachine2011
Jun 10, 2013, 1:09 PM
Thanks daniil, I could do it with store sort method.