Ericko
Ericko

Reputation: 132

jqGrid special Sorting

I have this data presented in a view with a jqGrid table. It has a complex sorting order of rows done server side.

Now I need to be able to do some "free" sorting of the rows at the View.

By free I mean that the client needs to be able to move a row up or down to any place they want, skipping all the other sorting rules done at server.

Of course, this will need to be saved to the database later.

I thought that maybe add a column with an Up and Down arrow, that when clicked it will move the row to where it needs to be.

I'm not at my best with JavaScript, and I can't seem to find any examples of something similar to this anywhere.

Any tips on how could I approach do this? Or is there a better option?

Thanks.

Upvotes: 1

Views: 634

Answers (1)

Chad Ferguson
Chad Ferguson

Reputation: 3091

There is the Sortable Rows feature built into the jqGrid.

You set it up with the following API call:

jQuery("#yourgridid").jqGrid('sortableRows', options);

It uses the jquery-ui Sortable widget for this so the optional options parameter can be used for any of the available options for the widget which you can find here.

For Example:

jQuery("#yourgridid").jqGrid('sortableRows', { cursor: 'crosshair' });

You can see a sample of this on the Demo page. (New in Version 3.6 -> Sortable Rows)

Upvotes: 1

Related Questions