Forum

May 22nd, 2014
A A A

Please consider registering
guest

Log In Register

Register | Lost password?
Advanced Search

— Forum Scope —

  

— Match —

   

— Forum Options —

    

Wildcard usage:
*  matches any number of characters    %  matches exactly one character

Minimum search word length is 4 characters - maximum search word length is 84 characters

Topic RSS Related Topics
Cant sortGrid With Multiple Columns When multiSort=true
09/07/2013
17:27
OronMorad
Israel
Member
Forum Posts: 4
Member Since:
09/07/2013
Offline

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.

15/07/2013
11:47
tony
Sofia, Bulgaria
Moderator
Forum Posts: 7580
Member Since:
30/10/2007
Offline

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.
21/07/2013
11:43
OronMorad
Israel
Member
Forum Posts: 4
Member Since:
09/07/2013
Offline

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.

22/07/2013
16:41
tony
Sofia, Bulgaria
Moderator
Forum Posts: 7580
Member Since:
30/10/2007
Offline

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.
24/07/2013
12:14
OronMorad
Israel
Member
Forum Posts: 4
Member Since:
09/07/2013
Offline

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.

10/02/2014
11:56
Steve_Suarez
Member
Forum Posts: 4
Member Since:
10/02/2014
Offline

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.

10/02/2014
14:34
tony
Sofia, Bulgaria
Moderator
Forum Posts: 7580
Member Since:
30/10/2007
Offline

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.
10/02/2014
16:27
Steve_Suarez
Member
Forum Posts: 4
Member Since:
10/02/2014
Offline

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

12/02/2014
06:59
Steve_Suarez
Member
Forum Posts: 4
Member Since:
10/02/2014
Offline

Hi Tony, Any updates please?

12/02/2014
12:57
tony
Sofia, Bulgaria
Moderator
Forum Posts: 7580
Member Since:
30/10/2007
Offline
10

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.
14/02/2014
15:22
Steve_Suarez
Member
Forum Posts: 4
Member Since:
10/02/2014
Offline

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

 

30/05/2014
22:07
av21
Member
Forum Posts: 3
Member Since:
30/05/2014
Offline
12

Hi Tony, Even i am facing same problem just like steve. jqgrid always gives precedence to left most column for multisort.i was looking in detail at jquery.jqgrid.js for multi sort and what i felt that it always look at in colmodel sequence to append sort name . line 2239

ts.p.sortorder = "";
            $.each(cm, function(i){
                if(this.lso) {
                    if(i>0 && fs) {
                        sort += ", ";
                    }
                    splas = this.lso.split("-");
                    sort += cm[i].index || cm[i].name;
                    sort += " "+splas[splas.length-1];
                    fs = true;
                    ts.p.sortorder = splas[splas.length-1];
                }
            });
            ls = sort.lastIndexOf(ts.p.sortorder);
            sort = sort.substring(0, ls);
            ts.p.sortname = sort;

ts.p.sortname = sort; – this is always will be Left columm asc/desc, Right column asc/desc

No matter if you have sort order with Field2(right col), Field1(left col).

 

I also tried to change ts.p.sortname to proper sequence based on header click, though data is not sorting the way we click header. it always sorts left column and then right column.

Am i missing something here? trying to fix that issue but no luck. do you have any updates?

02/06/2014
17:19
tony
Sofia, Bulgaria
Moderator
Forum Posts: 7580
Member Since:
30/10/2007
Offline
13

Hello,

This will be updated and additionally to that there will be a possibility to define the multisort in way the user click on the column – i.e we will not count it from left to right.

Kind 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.
02/06/2014
17:38
av21
Member
Forum Posts: 3
Member Since:
30/05/2014
Offline
14

hey tony thanks for reply. but does it means we can not do reverse multisort with current version? if so is there any workaround for now? 

02/06/2014
21:38
av21
Member
Forum Posts: 3
Member Since:
30/05/2014
Offline
15

I have fix to this problem after modification of some part of the jquery.jqgrid.js file.

i am trying to post the code here somehow getting error. is there way i can attach js file here?

06/06/2014
12:11
tony
Sofia, Bulgaria
Moderator
Forum Posts: 7580
Member Since:
30/10/2007
Offline
16

Hello,

You can use diffrent editors – just go in your proffil and select BBcode editor if you have problem with this.
Also you can use GitHub to post changes.
Thank you.

Kind 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.
09/06/2014
17:36
tprebs
New Member
Forum Posts: 1
Member Since:
09/06/2014
Offline
17

Is there a work around for the right to left sorting issue? 

My current project is dependent on this before go live. 

Forum Timezone: Europe/Sofia

Most Users Ever Online: 215

Currently Online:
34 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1216

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11241

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10444

Posts: 30870

Newest Members: blgsyrmhnds, toadicusrex, re-gor, NoSalt, 80vele, George

Moderators: tony (7580), Rumen[Trirand] (81)

Administrators: admin (61)

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information