Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





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

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
sortable columns
07/12/2009
16:26
Avatar
csitol
NC
Member
Members
Forum Posts: 13
Member Since:
02/08/2009
sp_UserOfflineSmall Offline

Tony,

Is there any way to know if a column has been moved using the sortable option?

Thanks!

Phil M

UPDATE:

I did get this to work using the following code:

jQuery('#gview_gridId').bind('sortstop', function(event, ui) {alert('here');});

If you have a better way I'm certainly open to it!

Thanks!

08/12/2009
18:00
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

Yes you can use remapColumns parameter - you can get it via getGridParam method.

The index is the original position the value is the new one.

Regards

Tony

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.

08/12/2009
18:07
Avatar
csitol
NC
Member
Members
Forum Posts: 13
Member Since:
02/08/2009
sp_UserOfflineSmall Offline

Tony,

Thanks for the quick response.  I'm afraid I wasn't very clear in my original question.

I was aware of the remapColumns method.  However, what I was looking for was more of an event that would fire when the user moved a column using the drag and drop method.  I wanted to either set a flag in my program so that I would know I need to save the new column order or enable a button to alert the user that they needed to save the new order.

I've looked at the remapColumns method again and it appears to just reorder the columns.  Is there more to it than that?

Thanks!

PhilM

08/12/2009
18:38
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

Look at sortableColumns method in grid.jqueryui.js

You can add your own options via sortable.options options in the grid. Here you can define all available optins for sortable UI widget - if I understand right

Best Regards

Tony

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.

08/12/2009
18:46
Avatar
markw65
Member
Members
Forum Posts: 179
Member Since:
30/07/2009
sp_UserOfflineSmall Offline

There are a couple of ways to hook into the sortable columns feature. First, rather than just setting the sortable option to true, you need to set it to an object with your options:

$("#mygrid").jqGrid({

...

 sortable : { options : { <whatever sortable options you want> },

              update : function(perumtation) {},

            },

...

};

The "options" object (if provided) lets you override any of the usual sortable options (see documentation at jquery-ui website). The "update" function (if provided) gets called right after the columns are re-ordered, and gets passed the permutation that was used (the colModel has already been updated, and reflects the new order - the permutation just lets you know exactly what was done).

As a simplification, if all you want is to catch the update event, you can just do

    sortable : function(permutation) { <whatever> },

Mark

08/12/2009
18:48
Avatar
csitol
NC
Member
Members
Forum Posts: 13
Member Since:
02/08/2009
sp_UserOfflineSmall Offline

Mark, Tony:

Thank you very much!  That's exactly what I wanted.

PhilM

07/01/2010
18:01
Avatar
riverguardian
Member
Members
Forum Posts: 17
Member Since:
30/06/2009
sp_UserOfflineSmall Offline

I'm trying to do a remap columns with this:

sortable: {

        update: function(perm) {

            if (perm) {  

                $("#grid").jqGrid("remapColumns", perm, true);

                var colModels = $("#grid").getGridParam("colModel");

            }

        }

    }

but I keep on getting the same column order. Why is this?

07/01/2010
19:15
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

Maybe if you reored the call you will have the neded result i.e. cal getGridParam before remapColumns.

Regards

Tony

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.

13/04/2011
21:31
Avatar
zishan
New Member
Members
Forum Posts: 2
Member Since:
13/04/2011
sp_UserOfflineSmall Offline

You can capture column changes via the sortable parameter as described, but please note that the array passed to your callback will be relative to the current column order.  In other words, saving the array as is after moving multiple columns will not produce the desired results.  See my answer on stack overflow.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
16 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.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information