:: Forum >>

Sort Order - Getting direction manually does not work

I am just starting to evaluate ActiveWidgets and am getting along OK but having one issue I have not been able to resolve yet.

I have a Grid control with four columns of data, plus the first column reserved for a checkbox (using mode = "multi-row-marker") which in general is doing what I need, with one issue so far.

I need to keep track of the last sort that was used on the four data columns (the checkbox one is disabled from sorting) and after refreshing the data totally (which is working; currently using dvtGrid1.clearRowModel() to do so) I want to re-apply the same sort (using index and column data saved from before I do this).

Using the call for dvtGrid1.getSortColumn() I do get the appropriate index for the sort column. However, no matter how many ways I try to I cannot seem to get the direction for the sort.

Here is what I have tried thus far, with nothing (empty string) begin returned in ALL cases:

var dir = dvtGrid1.getSortDirection();
var dir = dvtGrid1.getSortProperty('direction');
var dir = dvtGrid1.getSortProperty("direction");

Obviously the last two are the same as far as js is concerned (I hope).

Any suggestions would be appreciated.

If the entire code is needed please let me know, but I cannot see why it should be needed since the call to get the column index seems to work fine, so I think in general it is working. The call that IS working to get the index is shown below (this returns the correct column index used):

var idx = dvtGrid1.getSortColumn();

By the way, it does not return the direction, not matter how many times I may click on the sort (in other words, not just if I click it only once, but all the time). If anyone can suggest something I am missing, it would be appreciated. If this is a bug, please let me know so that I can just go ahead and make a sort function to implement custom sorting (even though I do not think of this as really custom) and I will try to keep track of the sort order at that time and just pass it along to do the normal sort, and then I can use my own value to know what the last sorted direction was.

Thanks in advance for any assistance...
D J Switzer
Friday, March 27, 2009
You should get the index of the column first.
var mylastsortcol = dvtGrid1.getSortColumn();
dvtGrid1.getSortDirection(mylastsortcol);
Friday, March 27, 2009
yes, the sort direction is stored per column so you should use sorted column index when getting or setting sort direction.

var index = grid.getSortColumn();
var direction = grid.getSortDirection(index);

grid.setSortColumn(index);
grid.setSortDirection(direction, index);
Alex (ActiveWidgets)
Saturday, March 28, 2009

This topic is archived.


Back to support forum

Forum search