Forum
14:42
02/12/2010
We have grid with say 10 columns. These 10 columns are not directly mapped with database, so I can not use order by clause. Now I want to sort the grid when it show data first time base on column no. 3. How to achive this sorting ?
I have achived this by below script.....
gridComplete : function(){
$("#column3").click();
},
But this approch is not working consistently? Some time it sort asc or sometime desc orders? also in case if data is more than 700 rows the grid's javascript got currupted?
Please suggest me some right approch to solve the sorting issue???
15:46
10/08/2009
Hi dm,
I suppose your problem is in the way how you fill the grid. The best way will be the usage of data parameter of the jqGrid. In the way the data filled in the grid will be automatically sorted and the first page of data displayed. So the user can work with the grid in very comfortable way using local sorting by another column as default (column no. 3 in your case), go to another page and searching/filtering of the data. You can use Toolbar Searching if needed and so on.
If you do want to add the rows in old way with respect of addRowData for example you will have to reload the grid with the code like $("#list").trigger("reloadGrid"); after the grid is full filled to force the sorting of the data.
If all this not help, you should post the whole code (JavaScript + HTML) which can be used to reproduce your problem.
Best regards,
Oleg
20:42
26/08/2010
Hi,
I'm having the same issue, I need to sort locally on page load because my db query won't allow server side sorting. I'm not sure if I understand your first suggestion Oleg, but when I do $("#list").trigger("reloadGrid"); it doesn't work. I'm doing this inside of the loadComplete event, which I've heard is having similar issues. Even when trying to do the sortGrid() method inside of loadComplete it doesn't actually sort, it just displays the sort arrows. Does anyone have a solution?
Thanks in advance
01:24
10/08/2009
Sorry SomethingNew,
It is very difficult to explain the taste of something without to taste of it. Exactly the same is true if we write something about the code. Why you don't just post the code which you mean?
What I mean is very easy. Look at this example. One prepare an array with data which include additional 'id' property if it not exist already in the grid. Then create a jqGrid using the data as input. It's all. The data will be automatically sorted and paged. So you have no problem with the sorting and paging of the data after the filling jqGrid with addRowData used in a loop.
If my example not help you, then just post your example which has the problem.
Best regards
Oleg
08:29
02/12/2010
SomethingNew, we are on the same page and getting similar issue.
OlegK, i am using json to load the data into grid. But data that loaded first time is not sorted by default base on column3 but we want to show data sorted base on column3 first time only. We don't want user to click on column3 and then it sort.
According to your example data sorted base on id column by default. Now suppose same sorted data (means sorted by id) coming from server side and you want it to sort it base on amount column before it display on grid first time. I was able to do this by code:
gridComplete : function(){
$("#column3″).click();
},
But it has performance and some other issues
I hope I have cleared my point, please let me know if you need more inputs to understand our problem. Please suggest us right way to solve it.
23:16
10/08/2009
Hello dm,
the information that you use loadonce:true parameter is very important. In general you should send the data from the server in the sorted order. It you don't do this you can reload the grid, but because of usage of loadonce:true parameter you should do this a little tricky:
if (myGrid.jqGrid('getGridParam','datatype') === "json") {
setTimeout(function(){
myGrid.trigger("reloadGrid");
},100);
}
}
Next time it is better to post whole jqGrid definition. The person which will read the code could probably find some important settings (like in your case) which could be important to find a working solution.
Here is a small code example which you can see live.
Best regards
Oleg
Most Users Ever Online: 715
Currently Online:
25 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