Page 1 of 1

tableSort sorts all rows except row 0

Posted: Mon Jan 19, 2015 7:08 pm
by j&b
If I sort a table I noticed that only all rows>0 are correct sorted.

In your UNIT tablesort.pas I stop running program in line

table := CreateSortedTable(rve, table, Column, ..., FirstRow, LastRow); (proc function DoSortCurrentTable(rve: ...))

FirstRow is always 1.

If I set FirstRow to 0 ALL rows are correct sorted.

FirstRow:= 0; //jb
table := CreateSortedTable(rve, table, Column, ..., FirstRow, LastRow);


Is there a reason why FirstRow is always 1 or is that an error ?

Posted: Mon Jan 19, 2015 9:11 pm
by Sergey Tkachenko
Sorry, I do not understand the problem?

Do you mean that, even if you set FirstRow=0, the first row is not sorted?
I cannot reproduce it in the ActionTest demo. "Table | Sort..." command (that uses TableSort.pas) sorts the first row.

Posted: Tue Jan 20, 2015 6:56 am
by j&b
>>Do you mean that, even if you set FirstRow=0, the first row is not sorted?

No, first row is sorted

>>Sort..." command (that uses TableSort.pas) sorts the first row.

That is correct, if HasHeadingRow:= false; -->

I haven't read your hint
"If HeadingRow, the first [selected] row is not sorted."

Re: tableSort sorts all rows except row 0

Posted: Tue Jan 20, 2015 7:42 am
by j&b
I tried to sort only some rows of a table and my solution runs fine.
Can occur problems ?


1.
unit TableSort;

{$I RV_Defs.inc}

interface
uses
SysUtils, ...,
{$ENDIF}
RVStyle, RichView, RVEdit,
TableSort_Var_jb; //new created and saved in RichViewActions-folder

2.
unit TableSort_Var_jb; //new created
interface
var row1,row2: integer;
implementation
begin
row1:= -1; row2:= -1;
end.


3.
function DoSortCurrentTable(rve: TCustomRichViewEdit; ...
...
begin
Result := False;
GetRangeOfRowsForSorting(table, HasHeadingRow, False, FirstRow, LastRow);

//added
if (row1>-1) and (row2>-1) then begin
FirstRow:= row1; LastRow:= row2; //jb
end;
//end of added

table := CreateSortedTable(rve, table, Column, Ascending, IgnoreCase, DataType,
FirstRow, LastRow);
...


4.
... uses TableSort_Var_jb //added in my program
row1:= 3; row2:= 5; DataType:= (rvsdtString); //(rvsdtNumber);
if CanSortTable(rveTable) then sortCurrentTable(rve, rveTspalte1, richtung, grossKlein,false,DataType);
...

Posted: Thu Jan 22, 2015 8:31 am
by Sergey Tkachenko
Answered by email