Jump to content


Photo

Resorting a NextGrid


  • Please log in to reply
2 replies to this topic

#1 wvd_vegt

wvd_vegt

    Master Member

  • Honorable Members
  • PipPipPipPipPip
  • 710 posts
  • Gender:Male
  • Location:the Netherlands

Posted 21 March 2006 - 12:44 PM

Hi All,

To add a function to resort a grid after adding new rows, simply add the following procedure to NxGrid.pas:

CODE
procedure TNextGrid.ReSortGrid();

var

 i: Integer;

begin

 for i := 0 to Columns.Count -1 do

   if (Columns[i].Sorted) then

     SortColumn(Columns[i], Columns[i].SortKind = skAscending);  

end;


and add

CODE
   procedure ReSortGrid;


to the public section of TNextGrid's delaration.
G.W. van der Vegt

#2 MasterEvil

MasterEvil
  • Members
  • 104 posts
  • Location:Germany

Posted 21 March 2006 - 03:55 PM

Hello Wim,

thanks for your code, but isn't this not a real resort?
What if you've sorted skDescending and you resort?
The Grid will afterwards be sorted ASC?!?

I have made me a pretty similiar function in my project.
The only difference is that I change the Sorted attribute.
This is just a little annoying, because you have to set it to false first:

CODE
procedure TNextGrid.ReSortGrid();

var

 i: Integer;

begin

 for i := 0 to Columns.Count -1 do

   if (Columns[i].Sorted) then

   begin

     Columns[i].Sorted:=false;

     Columns[i].Sorted:=true;

   end;

end;


greetz
Steffen

#3 wvd_vegt

wvd_vegt

    Master Member

  • Honorable Members
  • PipPipPipPipPip
  • 710 posts
  • Gender:Male
  • Location:the Netherlands

Posted 21 March 2006 - 05:22 PM

Hi,

Thats where the:

CODE
Columns[i].SortKind = skAscending


comes into place. The Sortcolumn procedure takes a boolean parameter called 'ascended'.

All of the columns sorting parameters are untouched so it sorts exactly as it was sorted before adding new rows.

I tried it with a textual column sorting numerically and it worked correctly.
G.W. van der Vegt




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users