Forum
![sp_Feed](http://www.trirand.com/blog/wp-content/sp-resources/forum-themes/default/images/sp_Feed.png)
![sp_Related](http://www.trirand.com/blog/wp-content/sp-resources/forum-plugins/tags/resources/images/sp_Related.png)
![sp_TopicIcon](http://www.trirand.com/blog/wp-content/sp-resources/forum-themes/default/images/sp_TopicIcon.png)
02:16
![Avatar](http://www.trirand.com/blog/wp-content/forum-avatars/defaults/userdefault.png)
18/05/2014
![sp_UserOfflineSmall](http://www.trirand.com/blog/wp-content/sp-resources/forum-themes/default/images/sp_UserOfflineSmall.png)
So one problem lead to a solution that ended up causing another problem...
Problem #1:
My columns can vary from load to load so I hide/show them accordingly, but also adjust the sorting to a column that's valid on the backend. So if the previously sorted column no longer applies, a new one is chosen. However, jqGrid doesn't look for sorting variables in responses for the column header visuals to update.
Solution:
Within loadComplete I do: grid.jqGrid('sortGrid', data.sortBy, false, data.sortOrder.toLowerCase());
Obviously I don't want to unnecessarily loop things, so a reload isn't performed as part of this command.
Problem #2 (and bug):
Now what's happening is that the typical pagination controls aren't working. It won't advance beyond page 2. If I had to guess I'd say that the sortGrid method causes an internal page variable to reset to page 1. So while the visual still shows page 2, an attempt to move forward one page or backwards doesn't work because it thinks it's on page 1 already.
Thus, these work:
- Manually entering a page number / hitting enter
- Using the arrow control to go directly to the last page
And these don't:
- Incrementing up one page
- Decrementing down one page
- Going directly to the first page
All those behaviors make sense if you assume the logic thinks it's already on page one, which I'd put forth is the bug.
14:03
![Avatar](http://www.trirand.com/blog/wp-content/forum-avatars/defaults/moderatordefault.png)
Moderators
30/10/2007
![sp_UserOfflineSmall](http://www.trirand.com/blog/wp-content/sp-resources/forum-themes/default/images/sp_UserOfflineSmall.png)
Hello,
The idea to call sortGrid in loadComplete event is very dangerous. You will go to infity loop.
The reason for this is that sorGrid call again populate . When you populate you call loadComplete, which call again sortGrid and so on.
I think the best idea for this purpose is to use setGridParam to change the sortname parameter and sortorder one.
Regards
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
18:43
![Avatar](http://www.trirand.com/blog/wp-content/forum-avatars/defaults/userdefault.png)
18/05/2014
![sp_UserOfflineSmall](http://www.trirand.com/blog/wp-content/sp-resources/forum-themes/default/images/sp_UserOfflineSmall.png)
The idea to call sortGrid in loadComplete event is very dangerous. You will go to infity loop.
No it won't. The second parameter is whether you want it to initiate a reload. I specifically mentioned above that I use this to avoid an infinite loop.
I think the best idea for this purpose is to use setGridParam to change the sortname parameter and sortorder one.
Been there, tried that. setGridParam doesn't initiate any visual change to the column headers, which is what I'm trying to solve.
20:51
![Avatar](http://www.trirand.com/blog/wp-content/forum-avatars/defaults/userdefault.png)
18/05/2014
![sp_UserOfflineSmall](http://www.trirand.com/blog/wp-content/sp-resources/forum-themes/default/images/sp_UserOfflineSmall.png)
Here's a jsFiddle with an example of the problem.
In making that I learned that the issue only exists when sortGrid is executed within the loadComplete event handler. If it's executed separately then subequent navigation works fine. So whatever is happening that's messing up the behavior must be running internally after the loadComplete event fires, but since that's the last event in the data loading process, there's no option for me to execute sortGrid any later.
The only remaining option I can think of would be to set a timeout in loadComplete to execute sortGrid after jqGrid is finished doing whatever it does after that event. Seeing as though I'm just trying to fix a subtle visual this is a possibility, but might fall out of sync if a user paginates quickly, so clearly not ideal.
IMO the best solution would be for jqGrid to support server-side sorting defining. So if the server provides sort/order variables (or whatever is defined in prmNames) in the response, those will automatically overwrite whatever jqGrid already thinks sorting is. The server being the authorative source over how the data is actually sorted, it makes sense that it could tell jqGrid that for proper presenation. I actually expected this behavior to exist already and have returned sorting information this whole time...
14:38
![Avatar](http://www.trirand.com/blog/wp-content/forum-avatars/defaults/moderatordefault.png)
Moderators
30/10/2007
![sp_UserOfflineSmall](http://www.trirand.com/blog/wp-content/sp-resources/forum-themes/default/images/sp_UserOfflineSmall.png)
Hello,
The reload parameter if set to false does not reload the grid only if you are in the same sortname and same sortorder - this mean is your current grid setting is : column1 and the sortorder is asc, the grid will not be reloaded only if you
In all other cases you will got with reloading.
Please look here
Regards
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
Most Users Ever Online: 715
Currently Online:
37 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66