Author Topic: Preserve track changes when sorting  (Read 2706 times)

mshapiro

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 35
    • View Profile
Preserve track changes when sorting
« on: April 29, 2015, 05:48:19 am »
I have a grid using trackModel: { on: true }.  The sortIndx is "Name" and the grid can be sorted by any column. The User can make edits in several columns and then use a toolbar button to initiate a ranking function that, if successful, will populate the "Rank" column in all rows with an integer 1-n where n is the number of rows in the grid.  An Undo button is available to use "rollback" to rollback the current edits.  When ranking is successful, I would like to then sort the grid by the Rank column but not lose the ability to rollback the current edits.  Sorting by clicking the Rank column header will do this, but changing sortIndx to "Rank" and using refreshDataAndView (apparently) resets tracking.  Is there a way to refresh the grid with a different sort order and preserve tracking?  Thanks.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6282
    • View Profile
Re: Preserve track changes when sorting
« Reply #1 on: April 29, 2015, 12:07:33 pm »
There is a sort method which can be used for your case.

It's missing from the docs as it's not multiple column sorting ready yet, would be updated in upcoming version. Since your requirement is to sort single column, it can be used.

Code: [Select]
$grid.pqGrid('sort', { dataIndx: 'dataIndx of the column', dir: 'up/down' });

http://jsfiddle.net/31ej2crp/
« Last Edit: April 29, 2015, 12:09:09 pm by paramquery »

mshapiro

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: Preserve track changes when sorting
« Reply #2 on: May 01, 2015, 05:51:31 am »
This works fine unless the current sortIndx and sortDir are already what I want.  In that case using this method results in a toggle in the sort direction regardless of what is specified as "dir (unless I'm missing something).  I use this method to sort by another column and then by the column I want, that works.  Any other way to resort the grid using the active sortIndx and sortDir (and preserve track changes)?  I need to do this because the values in the sortIndx column may have changed.  Thanks.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6282
    • View Profile
Re: Preserve track changes when sorting
« Reply #3 on: May 04, 2015, 11:06:21 am »
Please use the latest version 2.4.1 to use the dir option of sort method.