-
1 Feb 2013 8:51 AM #1
Help with grid / store remote sorting under ExtJS 4.1.3
Help with grid / store remote sorting under ExtJS 4.1.3
My ultimate goal is to have a grid with remote sorting, but this seems like it is supported by setting 'remoteSort: true' on the store backing the grid itself.
My problem is once this is set and the columns are marked as sortable, clicking on sort does nothing. Is the expectation here that I would be implementing some custom logic on the grid sortchange event or do I have to configure something else to get the remote sorting?
Can anyone help me out by either pointing to further documentation or explaining what is needed to make remote sort work?
Oh, and this is under ExtJS 4.1.3, apparently 4.2 is going to bring some improvements to the Grid, but I can't upgrade until it goes stable.Last edited by whirling dervish; 4 Feb 2013 at 7:13 AM. Reason: corrected typo, casing is correct in the code
-
1 Feb 2013 5:39 PM #2
Besides marking the store as having "remoteSort: true" (careful on the casing...), you shouldn't have to do anything else, at least not on the ExtJS side. What you *will* need to do is to implement logic on the server side to:
- Recognize the sortParam that is sent through on the remote sort request (this can be configured on your store's proxy)
- Produce a record set that reflects the requested sortParam's configuration
- Return back a response that is in a format acceptable to your store's configured Reader
-
6 Feb 2013 10:41 AM #3
Hmm, I am not seeing the sort menu do anything client side. I don't see any requests being sent to the server and I don't see 'sortchange' being fired on my grid.
Anyone have any idea what might be going on here or how I could better debug this?
An important distinction is that I am using the lockable grid here, maybe I am seeing a bug.
EDIT: Just tried switching the grid over to a normal grid and I am seeing the same behavior.
EDIT 2: Ah it looks like it might be due to dataIndex missing in my column definitions. Adding that makes the sort event fire as expected.
-
6 Feb 2013 12:30 PM #4
Is it possible to set a default sort on a remote sorting store?
A few threads I've encountered mention 'sortInfo' on the store, but I am not seeing that documented anywhere, and it doesn't seem to be working for me.
-
6 Feb 2013 1:28 PM #5
You should just be able to set the sorters config on the store itself.
Code:sorters:[ { property:'age', direction:'DESC' }, { property:'firstName', direction:'ASC' } ]
-
6 Feb 2013 1:45 PM #6
Thanks, don't know how I missed that in the documentation. That works like a charm.
Only thing wrong with it is that it doesn't mark the column with the initial sort as being sorted, but that is a pretty minor issue.
-
6 Feb 2013 1:51 PM #7
-
6 Feb 2013 1:52 PM #8
Maybe it's because the property name doesn't match the name of the column.


Reply With Quote