Forum

July 10th, 2011
You must be logged in to post Login Register

Search Forums:


 






Cant sortGrid With Multiple Columns When multiSort=true

UserPost

17:27
09/07/2013


OronMorad

Israel

Member

posts 4

Hi,

great work with the grid so far.


Although, after upgrading to 4.5.2 and setting multiSort to true, I cant seem to be able to sort the grid with multiple columns by code.


i.e: 

jQuery("#grid").jqGrid('setGridParam', { sortname: "Field1 asc, Field2″, sortorder: "asc" }).trigger('reloadGrid');

or

jQuery("#grid").jqGrid('sortGrid', "Field1 asc, Field2″, true, "asc");

or any combination of the two actually.


Im using local data (by calling 'addRowData')


Will this be possible in the near future?

Thank you.


btw: the reloadGrid trigger is not working in this case, and when sorting via the GUI you can only sort by left->right order of the columns (i.e can sort by field2, field3 and then by field5, but cant field5, field2 and then by field3).
Although i saw posts regarding these issues already.

11:47
15/07/2013


tony

Sofia, Bulgaria

Moderator

posts 7383

Hello,


Thanks for this. Will maybe improve sortGrid function.


Currently in order to achieve this you will need to call sortGrid (in multiSort set to true) several times like this.

jQuery("#grid")

.jqGrid('sortGrid', "Field1″, true, "asc")

.jqGrid('sortGrid', "Field2″, true, "desc");


Regards

For professional UI suites for PHP, ASP.NET and ASP.NET MVC visit us at our commercial products site – trirand.net – by the very same guys that created jqGrid.

11:43
21/07/2013


OronMorad

Israel

Member

posts 4

Seems to be working, thanks alot!


Right now to walk around of the grid not minding the sort order i ask, i have to set each ColModel[index].lso to the opposite order.

And also, have to set the ColModel.firstsortorder to "desc", due to a bug that the multiSort function does this:

} else {
	cm[iCol].lso = so = cm.firstsortorder || 'asc';
}

instead of this (i think...)

} else {
	cm[iCol].lso = so = cm[iCol].firstsortorder || 'asc';
}


Hope you fix that too, 


Thanks for the help.

16:41
22/07/2013


tony

Sofia, Bulgaria

Moderator

posts 7383

Hello,


Thank you very much. Fixed in GitHub


Regards

For professional UI suites for PHP, ASP.NET and ASP.NET MVC visit us at our commercial products site - trirand.net - by the very same guys that created jqGrid.

12:14
24/07/2013


OronMorad

Israel

Member

posts 4

OronMorad said:

Right now to walk around of the grid not minding the sort order i ask, i have to set each ColModel[index].lso to the opposite order.


Great thanks.

Just making sure you know this is a different issue from the quote above.

11:56
10/02/2014


Steve_Suarez

Member

posts 4

Post edited 11:56 - 10/02/2014 by Steve_Suarez
Post edited 11:57 - 10/02/2014 by Steve_Suarez


Hi guys, I am using the jqgrid multisort for a project. My requirement is to sort the grid using a minimum of 1 and a maximum of 3 colums and always in ascending order. At the moment, when I am using the following method,

/*

jQuery("#grid")

.jqGrid('sortGrid', "Field1″, true, "asc")

.jqGrid('sortGrid', "Field2″, true, "asc");

*/

sorting happens correctly for the first time, but on second sort jqgrid automatically gets sort in descending order and on the 3rd sort the original condition (presort state) of jqgrid is restored. Please suggest me some way of fulfilling this requirement.

Thanks and Regards.

14:34
10/02/2014


tony

Sofia, Bulgaria

Moderator

posts 7383

Hello,


Should I understand that you execute the above code several times - i.e with asc parameter. How do you call the second and third sorting?


Regards

For professional UI suites for PHP, ASP.NET and ASP.NET MVC visit us at our commercial products site - trirand.net - by the very same guys that created jqGrid.

16:27
10/02/2014


Steve_Suarez

Member

posts 4

Post edited 16:29 - 10/02/2014 by Steve_Suarez


Hi Tony, thanks for such a quick reply!

This is how I have am doing it on my jsp -

When the user wants to sort the grid on multiple columns, she has to press a sort button provided on the screen. This will take her to a pop up window where all the columns of the grid by the name are shown. From these columns, she can select 1, 2 or 3 columns for sorting. An 'ok' button on the pop up will take her back to the main page. After this I execute the rest of the method. If she had selected only one field for sorting, I execute the follwing -

jQuery("#grid").jqGrid('sortGrid', "Field1″, true, "asc");

If she had selected 2 fields then I execute the following -

jQuery("#grid").jqGrid('sortGrid', "Field1″, true, "asc").jqGrid('sortGrid', "Field2″, true, "asc");

If she had selected 3 fields then I execute the following -

jQuery("#grid").jqGrid('sortGrid', "Field1″, true, "asc").jqGrid('sortGrid', "Field2″, true, "asc").jqGrid('sortGrid', "Field3″, true, "asc");

 

Now when she does any of these three actions for the very first time, everything is executed correctly, however if she tries to execute the 3rd action, for instance, second time, even though I have explicitley mentioned 'asc' as the sort criteria, the grid would sort in descending order and when the same action is done for a 3rd time the grid is restored to it's first time load state(unsorted state). After this the cycle repeats itself.

Hope this will help you in detecting the root cause of the problem.

Thanks again! Laugh

06:59
12/02/2014


Steve_Suarez

Member

posts 4

Post edited 07:00 - 12/02/2014 by Steve_Suarez


Hi Tony, Any updates please?

12:57
12/02/2014


tony

Sofia, Bulgaria

Moderator

posts 7383

Hello,


It seems that there is a problem with this. I will try to fix this for the upcomming release (very soon)


Regards

For professional UI suites for PHP, ASP.NET and ASP.NET MVC visit us at our commercial products site - trirand.net - by the very same guys that created jqGrid.

15:22
14/02/2014


Steve_Suarez

Member

posts 4

Post edited 20:35 - 14/02/2014 by Steve_Suarez


Hi Tony, I was able to implement my requirement by using 'GridUnload' for destroying the previous sorting cirteria and order. But I have run into another problem. It seems, at least to me, that jqgrid always gives precedence to the left most column while sorting with multiSort : true.

I mean even if I am executing the following command -

jQuery("#grid").jqGrid('sortGrid', "Field1″, true, "asc").jqGrid('sortGrid', "Field2″, true, "asc");

where I would expect the outcome to be a grid sorted on "Field1" first and then on "Field2", the outcome is this only when "Field1" is on the left of "Field2". Whenever the "Field1" is on the right of "Field2" the actual outcome will be a grid sorted on "Field2" first and then on "Field1".

Kindly tell me, whether my observation is a mistake from my end or is it actually a part of the behaviour of jqgrid and if it's a part of the behaviour of jqgrid, whether a work around exists or not?

Thanks a ton btw Smile

 



About the jQuery Grid Plugin - jqGrid forum

Most Users Ever Online:

215


Currently Online:

20 Guests

Forum Stats:

Groups: 1

Forums: 7

Topics: 10274

Posts: 30361

Membership:

There are 11038 Members

There have been 448 Guests

There is 1 Admin

There are 2 Moderators

Top Posters:

OlegK - 1210

markw65 - 179

kobruleht - 144

phicarre - 132

YamilBracho - 124

Renso - 118

Administrators: admin (60 Posts)

Moderators: tony (7383 Posts), Rumen[Trirand] (81 Posts)




Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information