in rxdbgrid in filter and sort form show ColumnCaption for user choise

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2513 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
alexs75
2012-09-17 10:07:41 +00:00
parent ffd4b105f4
commit b1827f8951
8 changed files with 554 additions and 430 deletions

View File

@ -54,16 +54,16 @@
<MinVersion Major="1" Release="18" Build="56" Valid="True"/> <MinVersion Major="1" Release="18" Build="56" Valid="True"/>
</Item4> </Item4>
</RequiredPackages> </RequiredPackages>
<Units Count="69"> <Units Count="74">
<Unit0> <Unit0>
<Filename Value="RxDBGridDemo.lpr"/> <Filename Value="RxDBGridDemo.lpr"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="RxDBGridDemo"/> <UnitName Value="RxDBGridDemo"/>
<EditorIndex Value="4"/> <EditorIndex Value="6"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<CursorPos X="9" Y="16"/> <CursorPos X="9" Y="16"/>
<UsageCount Value="56"/> <UsageCount Value="60"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit0> </Unit0>
<Unit1> <Unit1>
@ -77,7 +77,7 @@
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="196"/> <TopLine Value="196"/>
<CursorPos X="21" Y="201"/> <CursorPos X="21" Y="201"/>
<UsageCount Value="56"/> <UsageCount Value="60"/>
<Loaded Value="True"/> <Loaded Value="True"/>
<LoadedDesigner Value="True"/> <LoadedDesigner Value="True"/>
</Unit1> </Unit1>
@ -501,9 +501,9 @@
<IsVisibleTab Value="True"/> <IsVisibleTab Value="True"/>
<EditorIndex Value="1"/> <EditorIndex Value="1"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="1846"/> <TopLine Value="3384"/>
<CursorPos X="1" Y="1847"/> <CursorPos X="35" Y="3405"/>
<UsageCount Value="11"/> <UsageCount Value="13"/>
<Bookmarks Count="3"> <Bookmarks Count="3">
<Item0 X="3" Y="73" ID="1"/> <Item0 X="3" Y="73" ID="1"/>
<Item1 X="13" Y="328" ID="2"/> <Item1 X="13" Y="328" ID="2"/>
@ -553,11 +553,11 @@
<Unit64> <Unit64>
<Filename Value="/usr/local/share/lazarus/components/rxnew/vclutils.pas"/> <Filename Value="/usr/local/share/lazarus/components/rxnew/vclutils.pas"/>
<UnitName Value="vclutils"/> <UnitName Value="vclutils"/>
<EditorIndex Value="2"/> <EditorIndex Value="5"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="187"/> <TopLine Value="1"/>
<CursorPos X="11" Y="220"/> <CursorPos X="1" Y="35"/>
<UsageCount Value="10"/> <UsageCount Value="12"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit64> </Unit64>
<Unit65> <Unit65>
@ -570,12 +570,10 @@
<Unit66> <Unit66>
<Filename Value="/usr/local/share/lazarus/lcl/graphics.pp"/> <Filename Value="/usr/local/share/lazarus/lcl/graphics.pp"/>
<UnitName Value="Graphics"/> <UnitName Value="Graphics"/>
<EditorIndex Value="3"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="93"/> <TopLine Value="93"/>
<CursorPos X="3" Y="99"/> <CursorPos X="3" Y="99"/>
<UsageCount Value="10"/> <UsageCount Value="11"/>
<Loaded Value="True"/>
</Unit66> </Unit66>
<Unit67> <Unit67>
<Filename Value="/usr/local/share/lazarus/lcl/include/lclintf.inc"/> <Filename Value="/usr/local/share/lazarus/lcl/include/lclintf.inc"/>
@ -591,64 +589,180 @@
<CursorPos X="1" Y="190"/> <CursorPos X="1" Y="190"/>
<UsageCount Value="10"/> <UsageCount Value="10"/>
</Unit68> </Unit68>
<Unit69>
<Filename Value="/usr/local/share/lazarus/components/rxnew/rxsortby.pas"/>
<ComponentName Value="rxSortByForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="rxsortby"/>
<EditorIndex Value="4"/>
<WindowIndex Value="0"/>
<TopLine Value="50"/>
<CursorPos X="14" Y="65"/>
<UsageCount Value="12"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit69>
<Unit70>
<Filename Value="/usr/local/share/lazarus/components/rxnew/rxfilterby.pas"/>
<ComponentName Value="rxFilterByForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="rxfilterby"/>
<EditorIndex Value="2"/>
<WindowIndex Value="0"/>
<TopLine Value="315"/>
<CursorPos X="1" Y="350"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit70>
<Unit71>
<Filename Value="../../../../../../install/source/fpcsrc/rtl/objpas/classes/classesh.inc"/>
<WindowIndex Value="0"/>
<TopLine Value="645"/>
<CursorPos X="15" Y="666"/>
<UsageCount Value="10"/>
</Unit71>
<Unit72>
<Filename Value="../../../../../../install/source/fpcsrc/rtl/objpas/classes/stringl.inc"/>
<WindowIndex Value="0"/>
<TopLine Value="593"/>
<CursorPos X="3" Y="598"/>
<UsageCount Value="10"/>
</Unit72>
<Unit73>
<Filename Value="/usr/local/share/lazarus/components/rxnew/rxstrutils.pas"/>
<UnitName Value="rxstrutils"/>
<EditorIndex Value="3"/>
<WindowIndex Value="0"/>
<TopLine Value="140"/>
<CursorPos X="23" Y="168"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit73>
</Units> </Units>
<JumpHistory Count="14" HistoryIndex="13"> <JumpHistory Count="30" HistoryIndex="29">
<Position1> <Position1>
<Filename Value="/usr/local/share/lazarus/lcl/graphics.pp"/> <Filename Value="/usr/local/share/lazarus/components/rxnew/rxsortby.pas"/>
<Caret Line="1179" Column="14" TopLine="1128"/> <Caret Line="72" Column="7" TopLine="53"/>
</Position1> </Position1>
<Position2> <Position2>
<Filename Value="/usr/local/share/lazarus/components/rxnew/vclutils.pas"/> <Filename Value="/usr/local/share/lazarus/components/rxnew/rxsortby.pas"/>
<Caret Line="227" Column="1" TopLine="203"/> <Caret Line="87" Column="14" TopLine="52"/>
</Position2> </Position2>
<Position3> <Position3>
<Filename Value="/usr/local/share/lazarus/components/rxnew/vclutils.pas"/> <Filename Value="/usr/local/share/lazarus/components/rxnew/rxsortby.pas"/>
<Caret Line="228" Column="1" TopLine="203"/> <Caret Line="245" Column="64" TopLine="222"/>
</Position3> </Position3>
<Position4> <Position4>
<Filename Value="/usr/local/share/lazarus/components/rxnew/vclutils.pas"/> <Filename Value="/usr/local/share/lazarus/components/rxnew/rxdbgrid.pas"/>
<Caret Line="316" Column="1" TopLine="295"/> <Caret Line="3476" Column="64" TopLine="3441"/>
</Position4> </Position4>
<Position5> <Position5>
<Filename Value="/usr/local/share/lazarus/components/rxnew/rxdbgrid.pas"/> <Filename Value="/usr/local/share/lazarus/components/rxnew/rxsortby.pas"/>
<Caret Line="1867" Column="19" TopLine="1842"/> <Caret Line="96" Column="25" TopLine="67"/>
</Position5> </Position5>
<Position6> <Position6>
<Filename Value="/usr/local/share/lazarus/lcl/graphics.pp"/> <Filename Value="/usr/local/share/lazarus/components/rxnew/rxsortby.pas"/>
<Caret Line="1179" Column="14" TopLine="1158"/> <Caret Line="69" Column="7" TopLine="41"/>
</Position6> </Position6>
<Position7> <Position7>
<Filename Value="/usr/local/share/lazarus/components/rxnew/rxdbgrid.pas"/> <Filename Value="/usr/local/share/lazarus/components/rxnew/rxsortby.pas"/>
<Caret Line="1869" Column="33" TopLine="1842"/> <Caret Line="118" Column="45" TopLine="94"/>
</Position7> </Position7>
<Position8> <Position8>
<Filename Value="/usr/local/share/lazarus/components/rxnew/rxdbgrid.pas"/> <Filename Value="/usr/local/share/lazarus/components/rxnew/rxsortby.pas"/>
<Caret Line="1867" Column="19" TopLine="1846"/> <Caret Line="256" Column="3" TopLine="235"/>
</Position8> </Position8>
<Position9> <Position9>
<Filename Value="/usr/local/share/lazarus/lcl/graphics.pp"/> <Filename Value="/usr/local/share/lazarus/components/rxnew/rxsortby.pas"/>
<Caret Line="1179" Column="14" TopLine="1158"/> <Caret Line="260" Column="1" TopLine="238"/>
</Position9> </Position9>
<Position10> <Position10>
<Filename Value="/usr/local/share/lazarus/components/rxnew/rxdbgrid.pas"/> <Filename Value="/usr/local/share/lazarus/components/rxnew/rxdbgrid.pas"/>
<Caret Line="1867" Column="19" TopLine="1846"/> <Caret Line="3476" Column="29" TopLine="3455"/>
</Position10> </Position10>
<Position11> <Position11>
<Filename Value="/usr/local/share/lazarus/components/rxnew/rxdbgrid.pas"/> <Filename Value="/usr/local/share/lazarus/components/rxnew/rxsortby.pas"/>
<Caret Line="1870" Column="19" TopLine="1846"/> <Caret Line="223" Column="1" TopLine="181"/>
</Position11> </Position11>
<Position12> <Position12>
<Filename Value="/usr/local/share/lazarus/lcl/graphics.pp"/> <Filename Value="/usr/local/share/lazarus/components/rxnew/rxsortby.pas"/>
<Caret Line="1179" Column="14" TopLine="1158"/> <Caret Line="70" Column="21" TopLine="50"/>
</Position12> </Position12>
<Position13> <Position13>
<Filename Value="/usr/local/share/lazarus/components/rxnew/rxdbgrid.pas"/> <Filename Value="/usr/local/share/lazarus/components/rxnew/rxdbgrid.pas"/>
<Caret Line="1870" Column="15" TopLine="1846"/> <Caret Line="3477" Column="34" TopLine="3455"/>
</Position13> </Position13>
<Position14> <Position14>
<Filename Value="/usr/local/share/lazarus/components/rxnew/vclutils.pas"/> <Filename Value="/usr/local/share/lazarus/components/rxnew/rxdbgrid.pas"/>
<Caret Line="298" Column="3" TopLine="280"/> <Caret Line="1483" Column="3" TopLine="1465"/>
</Position14> </Position14>
<Position15>
<Filename Value="/usr/local/share/lazarus/components/rxnew/rxdbgrid.pas"/>
<Caret Line="3400" Column="3" TopLine="3394"/>
</Position15>
<Position16>
<Filename Value="/usr/local/share/lazarus/components/rxnew/rxfilterby.pas"/>
<Caret Line="240" Column="2" TopLine="223"/>
</Position16>
<Position17>
<Filename Value="/usr/local/share/lazarus/components/rxnew/rxfilterby.pas"/>
<Caret Line="277" Column="1" TopLine="264"/>
</Position17>
<Position18>
<Filename Value="/usr/local/share/lazarus/components/rxnew/rxfilterby.pas"/>
<Caret Line="104" Column="41" TopLine="84"/>
</Position18>
<Position19>
<Filename Value="/usr/local/share/lazarus/components/rxnew/rxfilterby.pas"/>
<Caret Line="105" Column="5" TopLine="88"/>
</Position19>
<Position20>
<Filename Value="/usr/local/share/lazarus/components/rxnew/rxfilterby.pas"/>
<Caret Line="182" Column="37" TopLine="181"/>
</Position20>
<Position21>
<Filename Value="/usr/local/share/lazarus/components/rxnew/rxfilterby.pas"/>
<Caret Line="129" Column="17" TopLine="107"/>
</Position21>
<Position22>
<Filename Value="/usr/local/share/lazarus/components/rxnew/rxfilterby.pas"/>
<Caret Line="182" Column="36" TopLine="161"/>
</Position22>
<Position23>
<Filename Value="/usr/local/share/lazarus/components/rxnew/rxfilterby.pas"/>
<Caret Line="109" Column="15" TopLine="103"/>
</Position23>
<Position24>
<Filename Value="/usr/local/share/lazarus/components/rxnew/rxfilterby.pas"/>
<Caret Line="199" Column="5" TopLine="168"/>
</Position24>
<Position25>
<Filename Value="/usr/local/share/lazarus/components/rxnew/rxfilterby.pas"/>
<Caret Line="234" Column="12" TopLine="213"/>
</Position25>
<Position26>
<Filename Value="/usr/local/share/lazarus/components/rxnew/rxfilterby.pas"/>
<Caret Line="222" Column="30" TopLine="192"/>
</Position26>
<Position27>
<Filename Value="/usr/local/share/lazarus/components/rxnew/rxfilterby.pas"/>
<Caret Line="291" Column="12" TopLine="271"/>
</Position27>
<Position28>
<Filename Value="/usr/local/share/lazarus/components/rxnew/rxfilterby.pas"/>
<Caret Line="293" Column="1" TopLine="277"/>
</Position28>
<Position29>
<Filename Value="/usr/local/share/lazarus/components/rxnew/rxfilterby.pas"/>
<Caret Line="136" Column="16" TopLine="107"/>
</Position29>
<Position30>
<Filename Value="/usr/local/share/lazarus/components/rxnew/rxdbgrid.pas"/>
<Caret Line="3400" Column="3" TopLine="3394"/>
</Position30>
</JumpHistory> </JumpHistory>
</ProjectOptions> </ProjectOptions>
<CompilerOptions> <CompilerOptions>

View File

@ -421,8 +421,7 @@ type
FSortingNow:Boolean; FSortingNow:Boolean;
FInProcessCalc: integer; FInProcessCalc: integer;
FAllowedOperations: TRxDBGridAllowedOperations; FAllowedOperations: TRxDBGridAllowedOperations;
//FFooterColor: TColor; //
//FFooterRowCount: integer;
FKeyStrokes: TRxDBGridKeyStrokes; FKeyStrokes: TRxDBGridKeyStrokes;
FOnGetCellProps: TGetCellPropsEvent; FOnGetCellProps: TGetCellPropsEvent;
FOptionsRx: TOptionsRx; FOptionsRx: TOptionsRx;
@ -436,6 +435,7 @@ type
FSortOrder: TSortMarker; FSortOrder: TSortMarker;
FSortEngine: TRxDBGridSortEngine; FSortEngine: TRxDBGridSortEngine;
FPressedCol: TColumn; FPressedCol: TColumn;
//
FPressed: boolean; FPressed: boolean;
FSwapButtons: boolean; FSwapButtons: boolean;
FTracking: boolean; FTracking: boolean;
@ -2594,6 +2594,10 @@ begin
FSortEngine.Sort(FSortField, DataSource.DataSet, FSortOrder = FSortEngine.Sort(FSortField, DataSource.DataSet, FSortOrder =
smUp, SortEngineOptions); smUp, SortEngineOptions);
FSortingNow:=false; FSortingNow:=false;
F_SortListField.Clear;
if Assigned(FSortField) then
F_SortListField.Add(FSortField.FieldName);
end end
else else
HeaderClick(True, ACol); HeaderClick(True, ACol);
@ -3398,7 +3402,7 @@ begin
OptionsRx := OptionsRx - [rdgFilter]; OptionsRx := OptionsRx - [rdgFilter];
rxFilterByForm := TrxFilterByForm.Create(Application); rxFilterByForm := TrxFilterByForm.Create(Application);
NewFilter := DataSource.DataSet.Filter; NewFilter := DataSource.DataSet.Filter;
if rxFilterByForm.Execute(DataSource.DataSet, NewFilter, F_LastFilter) then if rxFilterByForm.Execute(Self, NewFilter, F_LastFilter) then
begin begin
if NewFilter <> '' then if NewFilter <> '' then
begin begin
@ -3473,7 +3477,7 @@ begin
rxSortByForm := TrxSortByForm.Create(Application); rxSortByForm := TrxSortByForm.Create(Application);
rxSortByForm.CheckBox1.Checked := rdgCaseInsensitiveSort in FOptionsRx; rxSortByForm.CheckBox1.Checked := rdgCaseInsensitiveSort in FOptionsRx;
o := not (FSortOrder = smDown); o := not (FSortOrder = smDown);
if rxSortByForm.Execute(DataSource.DataSet, F_SortListField, o) then if rxSortByForm.Execute(Self, F_SortListField, o) then
begin begin
for i := 0 to F_SortListField.Count - 1 do for i := 0 to F_SortListField.Count - 1 do
begin begin

View File

@ -9,14 +9,14 @@ object rxFilterByForm: TrxFilterByForm
ClientWidth = 644 ClientWidth = 644
OnCreate = FormCreate OnCreate = FormCreate
Position = poScreenCenter Position = poScreenCenter
LCLVersion = '0.9.31' LCLVersion = '1.1'
object Label1: TLabel object Label1: TLabel
AnchorSideLeft.Control = Owner AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner AnchorSideTop.Control = Owner
Left = 6 Left = 6
Height = 18 Height = 15
Top = 6 Top = 6
Width = 235 Width = 234
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'Select filter expression for data' Caption = 'Select filter expression for data'
Font.Style = [fsBold] Font.Style = [fsBold]
@ -28,9 +28,9 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideTop.Control = Label1 AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 6 Left = 6
Height = 18 Height = 15
Top = 30 Top = 27
Width = 63 Width = 62
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'On field:' Caption = 'On field:'
Font.Color = clRed Font.Color = clRed
@ -42,9 +42,9 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideTop.Control = Label1 AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 168 Left = 168
Height = 18 Height = 15
Top = 30 Top = 27
Width = 84 Width = 83
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'Operation :' Caption = 'Operation :'
Font.Color = clRed Font.Color = clRed
@ -56,9 +56,9 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideTop.Control = Label1 AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 271 Left = 271
Height = 18 Height = 15
Top = 30 Top = 27
Width = 89 Width = 88
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'Conditions :' Caption = 'Conditions :'
Font.Color = clRed Font.Color = clRed
@ -71,9 +71,9 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideTop.Control = Label1 AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 533 Left = 533
Height = 18 Height = 15
Top = 30 Top = 27
Width = 75 Width = 74
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'Operand :' Caption = 'Operand :'
Font.Color = clRed Font.Color = clRed
@ -87,9 +87,9 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideBottom.Control = ComboBox25 AnchorSideBottom.Control = ComboBox25
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 527 Left = 527
Height = 18 Height = 15
Top = 343 Top = 358
Width = 34 Width = 33
Anchors = [akLeft, akBottom] Anchors = [akLeft, akBottom]
Caption = 'End.' Caption = 'End.'
Font.Color = clRed Font.Color = clRed
@ -102,8 +102,8 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideTop.Control = Label2 AnchorSideTop.Control = Label2
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 6 Left = 6
Height = 27 Height = 29
Top = 54 Top = 48
Width = 153 Width = 153
BorderSpacing.Around = 6 BorderSpacing.Around = 6
ItemHeight = 0 ItemHeight = 0
@ -114,8 +114,8 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideTop.Control = Label2 AnchorSideTop.Control = Label2
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 168 Left = 168
Height = 27 Height = 29
Top = 54 Top = 48
Width = 96 Width = 96
BorderSpacing.Around = 6 BorderSpacing.Around = 6
DropDownCount = 9 DropDownCount = 9
@ -129,8 +129,8 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = ComboBox3 AnchorSideRight.Control = ComboBox3
Left = 271 Left = 271
Height = 23 Height = 25
Top = 54 Top = 48
Width = 250 Width = 250
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Around = 6 BorderSpacing.Around = 6
@ -143,8 +143,8 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 527 Left = 527
Height = 27 Height = 29
Top = 54 Top = 48
Width = 111 Width = 111
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
BorderSpacing.Around = 6 BorderSpacing.Around = 6
@ -163,8 +163,8 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideRight.Control = ComboBox1 AnchorSideRight.Control = ComboBox1
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 8 Left = 8
Height = 27 Height = 29
Top = 89 Top = 85
Width = 149 Width = 149
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6 BorderSpacing.Left = 6
@ -181,8 +181,8 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideRight.Control = ComboBox2 AnchorSideRight.Control = ComboBox2
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 168 Left = 168
Height = 27 Height = 29
Top = 87 Top = 83
Width = 96 Width = 96
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6 BorderSpacing.Top = 6
@ -199,8 +199,8 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = ComboBox3 AnchorSideRight.Control = ComboBox3
Left = 270 Left = 270
Height = 23 Height = 25
Top = 87 Top = 83
Width = 251 Width = 251
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6 BorderSpacing.Left = 6
@ -214,8 +214,8 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 527 Left = 527
Height = 27 Height = 29
Top = 87 Top = 83
Width = 111 Width = 111
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
BorderSpacing.Around = 6 BorderSpacing.Around = 6
@ -234,8 +234,8 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideRight.Control = ComboBox1 AnchorSideRight.Control = ComboBox1
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 8 Left = 8
Height = 27 Height = 29
Top = 124 Top = 122
Width = 149 Width = 149
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6 BorderSpacing.Left = 6
@ -252,8 +252,8 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideRight.Control = ComboBox2 AnchorSideRight.Control = ComboBox2
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 168 Left = 168
Height = 27 Height = 29
Top = 122 Top = 120
Width = 96 Width = 96
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6 BorderSpacing.Top = 6
@ -270,8 +270,8 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = ComboBox3 AnchorSideRight.Control = ComboBox3
Left = 270 Left = 270
Height = 23 Height = 25
Top = 122 Top = 120
Width = 251 Width = 251
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6 BorderSpacing.Left = 6
@ -285,8 +285,8 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 527 Left = 527
Height = 27 Height = 29
Top = 122 Top = 120
Width = 111 Width = 111
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
BorderSpacing.Around = 6 BorderSpacing.Around = 6
@ -305,7 +305,7 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideRight.Control = ComboBox1 AnchorSideRight.Control = ComboBox1
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 8 Left = 8
Height = 27 Height = 29
Top = 159 Top = 159
Width = 149 Width = 149
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
@ -323,7 +323,7 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideRight.Control = ComboBox2 AnchorSideRight.Control = ComboBox2
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 168 Left = 168
Height = 27 Height = 29
Top = 157 Top = 157
Width = 96 Width = 96
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
@ -341,7 +341,7 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = ComboBox3 AnchorSideRight.Control = ComboBox3
Left = 270 Left = 270
Height = 23 Height = 25
Top = 157 Top = 157
Width = 251 Width = 251
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
@ -356,7 +356,7 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 527 Left = 527
Height = 27 Height = 29
Top = 157 Top = 157
Width = 111 Width = 111
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
@ -376,8 +376,8 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideRight.Control = ComboBox1 AnchorSideRight.Control = ComboBox1
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 8 Left = 8
Height = 27 Height = 29
Top = 194 Top = 196
Width = 149 Width = 149
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6 BorderSpacing.Left = 6
@ -394,8 +394,8 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideRight.Control = ComboBox2 AnchorSideRight.Control = ComboBox2
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 168 Left = 168
Height = 27 Height = 29
Top = 192 Top = 194
Width = 96 Width = 96
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6 BorderSpacing.Top = 6
@ -412,8 +412,8 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = ComboBox3 AnchorSideRight.Control = ComboBox3
Left = 270 Left = 270
Height = 23 Height = 25
Top = 192 Top = 194
Width = 251 Width = 251
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6 BorderSpacing.Left = 6
@ -427,8 +427,8 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 527 Left = 527
Height = 27 Height = 29
Top = 192 Top = 194
Width = 111 Width = 111
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
BorderSpacing.Around = 6 BorderSpacing.Around = 6
@ -447,8 +447,8 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideRight.Control = ComboBox1 AnchorSideRight.Control = ComboBox1
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 8 Left = 8
Height = 27 Height = 29
Top = 229 Top = 233
Width = 149 Width = 149
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6 BorderSpacing.Left = 6
@ -465,8 +465,8 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideRight.Control = ComboBox2 AnchorSideRight.Control = ComboBox2
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 168 Left = 168
Height = 27 Height = 29
Top = 227 Top = 231
Width = 96 Width = 96
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6 BorderSpacing.Top = 6
@ -483,8 +483,8 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = ComboBox3 AnchorSideRight.Control = ComboBox3
Left = 270 Left = 270
Height = 23 Height = 25
Top = 227 Top = 231
Width = 251 Width = 251
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6 BorderSpacing.Left = 6
@ -498,8 +498,8 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 527 Left = 527
Height = 27 Height = 29
Top = 227 Top = 231
Width = 111 Width = 111
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
BorderSpacing.Around = 6 BorderSpacing.Around = 6
@ -518,8 +518,8 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideRight.Control = ComboBox1 AnchorSideRight.Control = ComboBox1
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 8 Left = 8
Height = 27 Height = 29
Top = 264 Top = 270
Width = 149 Width = 149
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6 BorderSpacing.Left = 6
@ -536,8 +536,8 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideRight.Control = ComboBox2 AnchorSideRight.Control = ComboBox2
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 168 Left = 168
Height = 27 Height = 29
Top = 262 Top = 268
Width = 96 Width = 96
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6 BorderSpacing.Top = 6
@ -554,8 +554,8 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = ComboBox3 AnchorSideRight.Control = ComboBox3
Left = 270 Left = 270
Height = 23 Height = 25
Top = 262 Top = 268
Width = 251 Width = 251
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6 BorderSpacing.Left = 6
@ -569,8 +569,8 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 527 Left = 527
Height = 27 Height = 29
Top = 262 Top = 268
Width = 111 Width = 111
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
BorderSpacing.Around = 6 BorderSpacing.Around = 6
@ -589,8 +589,8 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideRight.Control = ComboBox1 AnchorSideRight.Control = ComboBox1
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 8 Left = 8
Height = 27 Height = 29
Top = 299 Top = 307
Width = 149 Width = 149
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6 BorderSpacing.Left = 6
@ -607,8 +607,8 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideRight.Control = ComboBox2 AnchorSideRight.Control = ComboBox2
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 168 Left = 168
Height = 27 Height = 29
Top = 297 Top = 305
Width = 96 Width = 96
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6 BorderSpacing.Top = 6
@ -625,8 +625,8 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = ComboBox3 AnchorSideRight.Control = ComboBox3
Left = 270 Left = 270
Height = 23 Height = 25
Top = 297 Top = 305
Width = 251 Width = 251
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6 BorderSpacing.Left = 6
@ -640,8 +640,8 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 527 Left = 527
Height = 27 Height = 29
Top = 297 Top = 305
Width = 111 Width = 111
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
BorderSpacing.Around = 6 BorderSpacing.Around = 6
@ -660,8 +660,8 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideRight.Control = ComboBox1 AnchorSideRight.Control = ComboBox1
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 8 Left = 8
Height = 27 Height = 29
Top = 334 Top = 344
Width = 149 Width = 149
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6 BorderSpacing.Left = 6
@ -678,8 +678,8 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideRight.Control = ComboBox2 AnchorSideRight.Control = ComboBox2
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 168 Left = 168
Height = 27 Height = 29
Top = 332 Top = 342
Width = 96 Width = 96
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6 BorderSpacing.Top = 6
@ -696,8 +696,8 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = ComboBox3 AnchorSideRight.Control = ComboBox3
Left = 270 Left = 270
Height = 23 Height = 25
Top = 332 Top = 342
Width = 251 Width = 251
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6 BorderSpacing.Left = 6
@ -710,8 +710,8 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideBottom.Control = Owner AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 6 Left = 6
Height = 27 Height = 29
Top = 412 Top = 410
Width = 58 Width = 58
Anchors = [akLeft, akBottom] Anchors = [akLeft, akBottom]
BorderSpacing.Around = 6 BorderSpacing.Around = 6
@ -729,10 +729,10 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 597 Left = 592
Height = 23 Height = 27
Top = 416 Top = 412
Width = 41 Width = 46
Anchors = [akRight, akBottom] Anchors = [akRight, akBottom]
AutoSize = True AutoSize = True
BorderSpacing.Around = 6 BorderSpacing.Around = 6
@ -745,10 +745,10 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideRight.Control = Button1 AnchorSideRight.Control = Button1
AnchorSideBottom.Control = Owner AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 542 Left = 533
Height = 23 Height = 27
Top = 416 Top = 412
Width = 49 Width = 53
Anchors = [akRight, akBottom] Anchors = [akRight, akBottom]
AutoSize = True AutoSize = True
BorderSpacing.Around = 6 BorderSpacing.Around = 6
@ -761,10 +761,10 @@ object rxFilterByForm: TrxFilterByForm
AnchorSideRight.Control = Button2 AnchorSideRight.Control = Button2
AnchorSideBottom.Control = Owner AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 465 Left = 452
Height = 23 Height = 27
Top = 416 Top = 412
Width = 71 Width = 75
Anchors = [akRight, akBottom] Anchors = [akRight, akBottom]
AutoSize = True AutoSize = True
BorderSpacing.Around = 6 BorderSpacing.Around = 6

View File

@ -36,8 +36,8 @@ unit rxfilterby;
interface interface
uses uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs, Classes, SysUtils, FileUtil, rxdbgrid, LResources, Forms, Controls, Graphics,
StdCtrls, db; Dialogs, StdCtrls, db;
type type
@ -100,19 +100,20 @@ type
Combo_2 : Array[1..9] of TComboBox; Combo_2 : Array[1..9] of TComboBox;
Edit_1 : Array[1..9] of TEdit; Edit_1 : Array[1..9] of TEdit;
Combo_3 : Array[1..9] of TComboBox; Combo_3 : Array[1..9] of TComboBox;
Table : TDataSet;
procedure ClearALL(adoTable : TDataSet); FGrid : TRxDBGrid;
procedure ClearALL(AGrid : TRxDBGrid);
function FindCombo(CB:TComboBox):Integer; function FindCombo(CB:TComboBox):Integer;
function FindEdit(ED:TEdit):Integer; function FindEdit(ED:TEdit):Integer;
public public
function Execute(adoTable : TDataSet; Var FilterStr : String; Var LastFilter : TstringList):Boolean; function Execute(AGrid : TRxDBGrid; var FilterStr : String; var LastFilter : TstringList):Boolean;
end; end;
var var
rxFilterByForm: TrxFilterByForm; rxFilterByForm: TrxFilterByForm;
implementation implementation
uses rxdconst; uses rxdconst, rxstrutils, DBGrids;
{$R *.lfm} {$R *.lfm}
@ -120,12 +121,12 @@ uses rxdconst;
procedure TrxFilterByForm.Button2Click(Sender: TObject); procedure TrxFilterByForm.Button2Click(Sender: TObject);
begin begin
ModalResult := mrCancel; ModalResult := mrCancel;
end; end;
procedure TrxFilterByForm.Button3Click(Sender: TObject); procedure TrxFilterByForm.Button3Click(Sender: TObject);
begin begin
ClearALL(Table); ClearALL(FGrid);
end; end;
procedure TrxFilterByForm.ComboBoxChange(Sender: TObject); procedure TrxFilterByForm.ComboBoxChange(Sender: TObject);
@ -178,24 +179,25 @@ begin
ModalResult := mrOK; ModalResult := mrOK;
end; end;
procedure TrxFilterByForm.ClearALL(adoTable : TDataSet); procedure TrxFilterByForm.ClearALL(AGrid: TRxDBGrid);
var var
X : Integer; i : Integer;
begin begin
//***************************************************************************** //*****************************************************************************
Combo_1[1].Items.Clear; Combo_1[1].Items.Clear;
Combo_1[1].Items.Add(''); Combo_1[1].Items.Add('');
For X := 0 To adoTable.FieldCount-1 do for i := 0 To AGrid.Columns.Count-1 do
Begin begin
if (adoTable.Fields[X].FieldKind=fkData) And (adoTable.Fields[X].Visible) Then if (AGrid.Columns[i].Field.FieldKind=fkData) and (AGrid.Columns[i].Visible) then
Combo_1[1].Items.Add(adoTable.Fields[X].FieldName); Combo_1[1].Items.Objects[Combo_1[1].Items.Add(AGrid.Columns[i].Title.Caption)]:=AGrid.Columns[i].Field;
End; end;
Combo_1[1].ItemIndex := 0; Combo_1[1].ItemIndex := 0;
For X := 2 To 9 do for i := 2 To 9 do
Begin Begin
Combo_1[X].Items.Assign(Combo_1[1].Items); Combo_1[i].Items.Assign(Combo_1[1].Items);
Combo_1[X].ItemIndex := 0; Combo_1[i].ItemIndex := 0;
End; End;
Combo_2[1].Items.Clear; Combo_2[1].Items.Clear;
Combo_2[1].Items.Add(' = '); Combo_2[1].Items.Add(' = ');
@ -208,155 +210,160 @@ begin
Combo_2[1].Items.Add(' IS NULL '); Combo_2[1].Items.Add(' IS NULL ');
Combo_2[1].Items.Add(' IS NOT NULL '); Combo_2[1].Items.Add(' IS NOT NULL ');
Combo_2[1].ItemIndex := 0; Combo_2[1].ItemIndex := 0;
for X := 2 To 9 do for i := 2 To 9 do
begin begin
Combo_2[X].Items.Assign(Combo_2[1].Items); Combo_2[i].Items.Assign(Combo_2[1].Items);
Combo_2[X].ItemIndex := 0; Combo_2[i].ItemIndex := 0;
end; end;
for X := 1 To 9 do for i := 1 To 9 do
begin begin
Combo_3[X].ItemIndex := 0; Combo_3[i].ItemIndex := 0;
end; end;
for X := 1 To 9 do Edit_1[X].Text := ''; for i := 1 To 9 do Edit_1[i].Text := '';
//***************************************************************************** //*****************************************************************************
end; end;
function TrxFilterByForm.Execute(adoTable : TDataSet; Var FilterStr : String; Var LastFilter : TstringList):Boolean; function TrxFilterByForm.Execute(AGrid: TRxDBGrid; var FilterStr: String;
var LastFilter: TstringList): Boolean;
Var Var
X : Integer; X : Integer;
P : Integer; P : Integer;
S : String; S, S1 : String;
SD : String; SD : String;
FF : TField; C : TColumn;
Begin Begin
Result := False; Result := False;
//***************************************************************************** //*****************************************************************************
Combo_1[1]:= ComboBox1; Combo_1[1]:= ComboBox1;
Combo_1[2]:= ComboBox4; Combo_1[2]:= ComboBox4;
Combo_1[3]:= ComboBox7; Combo_1[3]:= ComboBox7;
Combo_1[4]:= ComboBox10; Combo_1[4]:= ComboBox10;
Combo_1[5]:= ComboBox13; Combo_1[5]:= ComboBox13;
Combo_1[6]:= ComboBox16; Combo_1[6]:= ComboBox16;
Combo_1[7]:= ComboBox19; Combo_1[7]:= ComboBox19;
Combo_1[8]:= ComboBox22; Combo_1[8]:= ComboBox22;
Combo_1[9]:= ComboBox25; Combo_1[9]:= ComboBox25;
Combo_2[1]:= ComboBox2; Combo_2[1]:= ComboBox2;
Combo_2[2]:= ComboBox5; Combo_2[2]:= ComboBox5;
Combo_2[3]:= ComboBox8; Combo_2[3]:= ComboBox8;
Combo_2[4]:= ComboBox11; Combo_2[4]:= ComboBox11;
Combo_2[5]:= ComboBox14; Combo_2[5]:= ComboBox14;
Combo_2[6]:= ComboBox17; Combo_2[6]:= ComboBox17;
Combo_2[7]:= ComboBox20; Combo_2[7]:= ComboBox20;
Combo_2[8]:= ComboBox23; Combo_2[8]:= ComboBox23;
Combo_2[9]:= ComboBox26; Combo_2[9]:= ComboBox26;
Combo_3[1]:= ComboBox3; Combo_3[1]:= ComboBox3;
Combo_3[2]:= ComboBox6; Combo_3[2]:= ComboBox6;
Combo_3[3]:= ComboBox9; Combo_3[3]:= ComboBox9;
Combo_3[4]:= ComboBox12; Combo_3[4]:= ComboBox12;
Combo_3[5]:= ComboBox15; Combo_3[5]:= ComboBox15;
Combo_3[6]:= ComboBox18; Combo_3[6]:= ComboBox18;
Combo_3[7]:= ComboBox21; Combo_3[7]:= ComboBox21;
Combo_3[8]:= ComboBox24; Combo_3[8]:= ComboBox24;
Combo_3[9]:= ComboBox27; Combo_3[9]:= ComboBox27;
Combo_3[9].Visible := False; Combo_3[9].Visible := False;
Edit_1[1] := Edit1; Edit_1[1] := Edit1;
Edit_1[2] := Edit2; Edit_1[2] := Edit2;
Edit_1[3] := Edit3; Edit_1[3] := Edit3;
Edit_1[4] := Edit4; Edit_1[4] := Edit4;
Edit_1[5] := Edit5; Edit_1[5] := Edit5;
Edit_1[6] := Edit6; Edit_1[6] := Edit6;
Edit_1[7] := Edit7; Edit_1[7] := Edit7;
Edit_1[8] := Edit8; Edit_1[8] := Edit8;
Edit_1[9] := Edit9; Edit_1[9] := Edit9;
//***************************************************************************** //*****************************************************************************
Table := adoTable; FGrid := AGrid;
ClearALL(Table); ClearALL(FGrid);
if LastFilter.Count > 0 Then if LastFilter.Count > 0 Then
Begin begin
For X := 0 To LastFilter.Count-1 do for X := 0 To LastFilter.Count-1 do
Begin begin
S := LastFilter.Strings[X]; S := LastFilter.Strings[X];
P := Pos('|||',S); P := Pos('|||',S);
if P > 0 Then if P > 0 Then
Begin begin
Combo_1[X+1].ItemIndex := Combo_1[X+1].Items.IndexOf(System.Copy(S,1,P-1)); S1:=System.Copy(S,1,P-1);
System.Delete(S,1,P+2); C:=FGrid.ColumnByFieldName(S1);
End; Combo_1[X+1].ItemIndex := Combo_1[X+1].Items.IndexOf(C.Title.Caption);
P := Pos('|||',S); System.Delete(S,1,P+2);
if P > 0 Then end;
Begin
SD:=System.Copy(S,1,P-1);
Combo_2[X+1].ItemIndex := Combo_2[X+1].Items.IndexOf(System.Copy(S,1,P-1));
System.Delete(S,1,P+2);
if (SD=' IS NULL ') or (SD=' IS NOT NULL ') Then
Begin
Edit_1[X+1].Text := '';
Edit_1[X+1].Enabled := False;
Edit_1[X+1].Color := clInactiveCaption;
End;
End;
P := Pos('|||',S);
if P > 0 Then
Begin
Edit_1[X+1].Text := System.Copy(S,1,P-1);
System.Delete(S,1,P+2);
End;
Combo_3[X+1].ItemIndex := Combo_3[X+1].Items.IndexOf(S);
if Combo_3[X+1].ItemIndex = -1 Then Combo_3[X+1].ItemIndex := 0;
End;
End;
ShowModal; P := Pos('|||',S);
if ModalResult=mrOK Then if P > 0 Then
Begin begin
Result := True; SD:=System.Copy(S,1,P-1);
FilterStr := ''; Combo_2[X+1].ItemIndex := Combo_2[X+1].Items.IndexOf(System.Copy(S,1,P-1));
LastFilter.Clear; System.Delete(S,1,P+2);
For X := 1 to 9 Do if (SD=' IS NULL ') or (SD=' IS NOT NULL ') Then
Begin Begin
if (Combo_1[X].Text <> '') Edit_1[X+1].Text:= '';
And (Combo_2[X].Text <> '') Then Edit_1[X+1].Enabled := False;
Begin Edit_1[X+1].Color := clInactiveCaption;
if (Edit_1[X].Enabled=False) or (Edit_1[X].Text <> '') Then End;
Begin end;
if X>1 Then
FilterStr := FilterStr+Combo_3[X-1].Text+' '; P := Pos('|||',S);
FF := Table.FindField(Combo_1[X].Text); if P > 0 then
Case FF.DataType of begin
ftDateTime , Edit_1[X+1].Text := System.Copy(S,1,P-1);
ftDate : FilterStr := FilterStr+'('+Combo_1[X].Text+Combo_2[X].Text+Char(39)+Copy(Edit_1[X].Text,7,4)+Copy(Edit_1[X].Text,3,4)+Copy(Edit_1[X].Text,1,2)+Copy(Edit_1[X].Text,11,9)+Char(39)+') '; System.Delete(S,1,P+2);
ftUnknown : FilterStr := FilterStr+'('+Combo_1[X].Text+Combo_2[X].Text+Edit_1[X].Text+') '; end;
ftTime, Combo_3[X+1].ItemIndex := Combo_3[X+1].Items.IndexOf(S);
ftString,
ftMemo : FilterStr := FilterStr+'('+Combo_1[X].Text+Combo_2[X].Text+Char(39)+Edit_1[X].Text+Char(39)+') '; if Combo_3[X+1].ItemIndex = -1 Then Combo_3[X+1].ItemIndex := 0;
else end;
FilterStr := FilterStr+'('+Combo_1[X].Text+Combo_2[X].Text+Edit_1[X].Text+') '; end;
End;
LastFilter.Add(Combo_1[X].Text+'|||'+Combo_2[X].Text+'|||'+Edit_1[X].Text+'|||'+Combo_3[X].Text); if ShowModal = mrOK Then
End; begin
End; Result := True;
End; FilterStr := '';
End; LastFilter.Clear;
End; for X := 1 to 9 Do
begin
if (Combo_1[X].Text <> '') and (Combo_2[X].Text <> '') then
begin
if (Edit_1[X].Enabled=False) or (Edit_1[X].Text <> '') Then
begin
if X>1 Then
FilterStr := FilterStr+Combo_3[X-1].Text+' ';
C:=FGrid.ColumnByCaption(Combo_1[X].Text);
case C.Field.DataType of
ftDateTime ,
ftDate : FilterStr := FilterStr+'('+C.FieldName+Combo_2[X].Text+Char(39)+Copy(Edit_1[X].Text,7,4)+Copy(Edit_1[X].Text,3,4)+Copy(Edit_1[X].Text,1,2)+Copy(Edit_1[X].Text,11,9)+Char(39)+') ';
ftUnknown : FilterStr := FilterStr+'('+C.FieldName+Combo_2[X].Text+Edit_1[X].Text+') ';
ftTime,
ftString,
ftMemo : FilterStr := FilterStr+'('+C.FieldName+Combo_2[X].Text+QuotedString(Edit_1[X].Text, '''')+') ';
else
FilterStr := FilterStr+'('+C.FieldName+Combo_2[X].Text+Edit_1[X].Text+') ';
end;
LastFilter.Add(C.FieldName+'|||'+Combo_2[X].Text+'|||'+Edit_1[X].Text+'|||'+Combo_3[X].Text);
end;
end;
end;
end;
end;
Function TrxFilterByForm.FindCombo(CB:TComboBox):Integer; Function TrxFilterByForm.FindCombo(CB:TComboBox):Integer;
Var var
X : Integer; X : Integer;
Begin begin
Result :=0; Result :=0;
For X := 1 to 9 do for X := 1 to 9 do
Begin begin
if Combo_2[X]=CB Then if Combo_2[X]=CB Then
Begin begin
Result := X; Result := X;
Exit; Exit;
End; end;
End; end;
End; end;
function TrxFilterByForm.FindEdit(ED:TEdit):Integer; function TrxFilterByForm.FindEdit(ED:TEdit):Integer;
var var

View File

@ -27,7 +27,7 @@ translate to Lazarus by alexs in 2005 - 2012
"/> "/>
<License Value="LGPL"/> <License Value="LGPL"/>
<Version Major="2" Minor="2" Release="2" Build="112"/> <Version Major="2" Minor="2" Release="2" Build="112"/>
<Files Count="64"> <Files Count="66">
<Item1> <Item1>
<Filename Value="autopanel.pas"/> <Filename Value="autopanel.pas"/>
<UnitName Value="AutoPanel"/> <UnitName Value="AutoPanel"/>
@ -287,6 +287,14 @@ translate to Lazarus by alexs in 2005 - 2012
<Filename Value="ex_rx_xml_datapacket.pas"/> <Filename Value="ex_rx_xml_datapacket.pas"/>
<UnitName Value="ex_rx_xml_datapacket"/> <UnitName Value="ex_rx_xml_datapacket"/>
</Item64> </Item64>
<Item65>
<Filename Value="rxsortby.lfm"/>
<Type Value="LFM"/>
</Item65>
<Item66>
<Filename Value="rxsortby.pas"/>
<UnitName Value="rxsortby"/>
</Item66>
</Files> </Files>
<LazDoc Paths="docs;\usr\local\share\lazarus\components\rxnew\docs"/> <LazDoc Paths="docs;\usr\local\share\lazarus\components\rxnew\docs"/>
<i18n> <i18n>

View File

@ -18,7 +18,7 @@ uses
RxSystemServices, rxtbrsetup, RxTimeEdit, rxtoolbar, RxVersInfo, RxSystemServices, rxtbrsetup, RxTimeEdit, rxtoolbar, RxVersInfo,
RxViewsPanel, rxxpman, seldsfrm, tooledit, vclutils, RxCloseFormValidator, RxViewsPanel, rxxpman, seldsfrm, tooledit, vclutils, RxCloseFormValidator,
RxHistoryNavigator, ex_rx_bin_datapacket, ex_rx_datapacket, RxHistoryNavigator, ex_rx_bin_datapacket, ex_rx_datapacket,
ex_rx_xml_datapacket, LazarusPackageIntf; ex_rx_xml_datapacket, rxsortby, LazarusPackageIntf;
implementation implementation

View File

@ -7,30 +7,29 @@ object rxSortByForm: TrxSortByForm
Caption = 'Sort by fields' Caption = 'Sort by fields'
ClientHeight = 411 ClientHeight = 411
ClientWidth = 684 ClientWidth = 684
OnClose = FormClose
OnCreate = FormCreate OnCreate = FormCreate
Position = poScreenCenter Position = poScreenCenter
LCLVersion = '0.9.31' LCLVersion = '1.1'
object Label1: TLabel object Label1: TLabel
AnchorSideLeft.Control = Owner AnchorSideLeft.Control = AddBtn
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Owner AnchorSideTop.Control = Owner
Left = 6 Left = 417
Height = 18 Height = 15
Top = 6 Top = 6
Width = 109 Width = 105
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = '&Fields for sorting:' Caption = '&Fields for sorting:'
FocusControl = ListBox1 FocusControl = ListBox1
ParentColor = False ParentColor = False
end end
object Label2: TLabel object Label2: TLabel
AnchorSideLeft.Control = AddBtn AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Owner AnchorSideTop.Control = Owner
Left = 415 Left = 6
Height = 18 Height = 15
Top = 6 Top = 6
Width = 57 Width = 55
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = '&All fields:' Caption = '&All fields:'
FocusControl = ListBox2 FocusControl = ListBox2
@ -41,9 +40,9 @@ object rxSortByForm: TrxSortByForm
AnchorSideBottom.Control = ComboBox1 AnchorSideBottom.Control = ComboBox1
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 6 Left = 6
Height = 18 Height = 15
Top = 318 Top = 314
Width = 108 Width = 104
Anchors = [akLeft, akBottom] Anchors = [akLeft, akBottom]
BorderSpacing.Left = 6 BorderSpacing.Left = 6
Caption = 'Select sort order' Caption = 'Select sort order'
@ -51,22 +50,20 @@ object rxSortByForm: TrxSortByForm
ParentColor = False ParentColor = False
end end
object ListBox2: TListBox object ListBox2: TListBox
AnchorSideLeft.Control = AddBtn AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Label2 AnchorSideTop.Control = Label2
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner AnchorSideRight.Control = AddBtn
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ComboBox1 AnchorSideBottom.Control = ComboBox1
Left = 415 Left = 6
Height = 273 Height = 267
Top = 30 Top = 27
Width = 263 Width = 262
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Around = 6 BorderSpacing.Around = 6
ItemHeight = 0 ItemHeight = 0
OnDblClick = ListBox2DblClick OnDblClick = ListBox2DblClick
ScrollWidth = 261 ScrollWidth = 260
TabOrder = 0 TabOrder = 0
TopIndex = -1 TopIndex = -1
end end
@ -76,10 +73,10 @@ object rxSortByForm: TrxSortByForm
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = AddBtn AnchorSideRight.Control = AddBtn
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 275 Left = 274
Height = 29 Height = 35
Top = 65 Top = 68
Width = 134 Width = 137
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
AutoSize = True AutoSize = True
BorderSpacing.Top = 6 BorderSpacing.Top = 6
@ -89,18 +86,16 @@ object rxSortByForm: TrxSortByForm
0400000000001401000000000000000000001000000010000000000000000000 0400000000001401000000000000000000001000000010000000000000000000
80000080000000808000800000008000800080800000C0C0C000808080000000 80000080000000808000800000008000800080800000C0C0C000808080000000
C80000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00777777777777 C80000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00777777777777
7777777777777777777777877777777777777777777777007777777777777777 7777777777777777777777777877777777777777777777770077777777777777
7777770907777777777777777777770990777777777777777777770999077777 7777777090777777777777777777770990777777777777777777709990777777
7777777777777709999077777777777800000009999907777777777099999999 7777777777770999907777777777777777709999900000008777777777099999
9999907777777770999999999999990777777770999999999999999077777770 999999990777777770999999999999990777777709999999999999990777777F
9999999999999999F7777770999999999999999F7777777099999999999999F7 999999999999999907777777F999999999999999077777777F99999999999999
777777709999999999999F7777777778FFFFFF899999F7777777777777777789 0777777777F999999999999907777777777F999998FFFFFF877777777777F999
999F7777777777777777778999F7777777777777777777899F77777777777777 987777777777777777777F999877777777777777777777F99877777777777777
77777789F7777777777777777777778F7777777777777777777777F777777777 7777777F987777777777777777777777F877777777777777777777777F777777
7777777777777777777777777777 7777777777777777777777777777
} }
Layout = blGlyphRight
NumGlyphs = 0
OnClick = RemoveBtnClick OnClick = RemoveBtnClick
TabOrder = 2 TabOrder = 2
end end
@ -110,10 +105,10 @@ object rxSortByForm: TrxSortByForm
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = AddBtn AnchorSideRight.Control = AddBtn
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 275 Left = 274
Height = 30 Height = 36
Top = 100 Top = 109
Width = 134 Width = 137
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
AutoSize = True AutoSize = True
BorderSpacing.Top = 6 BorderSpacing.Top = 6
@ -133,7 +128,6 @@ object rxSortByForm: TrxSortByForm
77777709F7777777777077777777777F77777777777077777777777777777777 77777709F7777777777077777777777F77777777777077777777777777777777
7770777777777777777777777770777777777777777777777770 7770777777777777777777777770777777777777777777777770
} }
NumGlyphs = 0
OnClick = UpBtnClick OnClick = UpBtnClick
TabOrder = 3 TabOrder = 3
end end
@ -143,10 +137,10 @@ object rxSortByForm: TrxSortByForm
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = AddBtn AnchorSideRight.Control = AddBtn
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 275 Left = 274
Height = 30 Height = 36
Top = 136 Top = 151
Width = 134 Width = 137
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
AutoSize = True AutoSize = True
BorderSpacing.Top = 6 BorderSpacing.Top = 6
@ -166,7 +160,6 @@ object rxSortByForm: TrxSortByForm
77709999999F7777777077777778000000087777777077777777777777777777 77709999999F7777777077777778000000087777777077777777777777777777
7770777777777777777777777770777777777777777777777770 7770777777777777777777777770777777777777777777777770
} }
NumGlyphs = 0
OnClick = DownBtnClick OnClick = DownBtnClick
TabOrder = 4 TabOrder = 4
end end
@ -176,10 +169,10 @@ object rxSortByForm: TrxSortByForm
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CheckBox1 AnchorSideBottom.Control = CheckBox1
Left = 120 Left = 116
Height = 27 Height = 29
Top = 309 Top = 300
Width = 558 Width = 562
Anchors = [akLeft, akRight, akBottom] Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Around = 6 BorderSpacing.Around = 6
ItemHeight = 0 ItemHeight = 0
@ -187,20 +180,22 @@ object rxSortByForm: TrxSortByForm
TabOrder = 5 TabOrder = 5
end end
object ListBox1: TListBox object ListBox1: TListBox
AnchorSideLeft.Control = Owner AnchorSideLeft.Control = AddBtn
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Label1 AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = AddBtn AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ComboBox1 AnchorSideBottom.Control = ComboBox1
Left = 6 Left = 417
Height = 273 Height = 267
Top = 30 Top = 27
Width = 263 Width = 261
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Around = 6 BorderSpacing.Around = 6
ItemHeight = 0 ItemHeight = 0
OnDblClick = ListBox1DblClick OnDblClick = ListBox1DblClick
ScrollWidth = 261 ScrollWidth = 259
TabOrder = 6 TabOrder = 6
TopIndex = -1 TopIndex = -1
end end
@ -208,10 +203,10 @@ object rxSortByForm: TrxSortByForm
AnchorSideLeft.Control = Owner AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = ListBox1 AnchorSideTop.Control = ListBox1
Left = 275 Left = 274
Height = 29 Height = 35
Top = 30 Top = 27
Width = 134 Width = 137
AutoSize = True AutoSize = True
Caption = '&Add field to sort' Caption = '&Add field to sort'
Glyph.Data = { Glyph.Data = {
@ -219,33 +214,33 @@ object rxSortByForm: TrxSortByForm
0400000000001401000000000000000000001000000010000000000000000000 0400000000001401000000000000000000001000000010000000000000000000
80000080000000808000800000008000800080800000C0C0C000808080000000 80000080000000808000800000008000800080800000C0C0C000808080000000
C80000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00777777777777 C80000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00777777777777
7777777777777777777777777877777777777777777777770077777777777777 7777777777777777777777877777777777777777777777007777777777777777
7777777090777777777777777777770990777777777777777777709990777777 7777770907777777777777777777770990777777777777777777770999077777
7777777777770999907777777777777777709999900000008777777777099999 7777777777777709999077777777777800000009999907777777777099999999
999999990777777770999999999999990777777709999999999999990777777F 9999907777777770999999999999990777777770999999999999999077777770
999999999999999907777777F999999999999999077777777F99999999999999 9999999999999999F7777770999999999999999F7777777099999999999999F7
0777777777F999999999999907777777777F999998FFFFFF877777777777F999 777777709999999999999F7777777778FFFFFF899999F7777777777777777789
987777777777777777777F999877777777777777777777F99877777777777777 999F7777777777777777778999F7777777777777777777899F77777777777777
7777777F987777777777777777777777F877777777777777777777777F777777 77777789F7777777777777777777778F7777777777777777777777F777777777
7777777777777777777777777777 7777777777777777777777777777
} }
NumGlyphs = 0 Layout = blGlyphRight
OnClick = AddBtnClick OnClick = AddBtnClick
TabOrder = 1 TabOrder = 1
end end
object ButtonPanel1: TButtonPanel object ButtonPanel1: TButtonPanel
Left = 6 Left = 6
Height = 36 Height = 42
Top = 369 Top = 363
Width = 672 Width = 672
OKButton.Name = 'OKButton' OKButton.Name = 'OKButton'
OKButton.Caption = '&ОК' OKButton.DefaultCaption = True
HelpButton.Name = 'HelpButton' HelpButton.Name = 'HelpButton'
HelpButton.Caption = '&Справка' HelpButton.DefaultCaption = True
CloseButton.Name = 'CloseButton' CloseButton.Name = 'CloseButton'
CloseButton.Caption = '&Закрыть' CloseButton.DefaultCaption = True
CancelButton.Name = 'CancelButton' CancelButton.Name = 'CancelButton'
CancelButton.Caption = 'Отмена' CancelButton.DefaultCaption = True
TabOrder = 7 TabOrder = 7
ShowButtons = [pbOK, pbCancel, pbHelp] ShowButtons = [pbOK, pbCancel, pbHelp]
end end
@ -255,9 +250,9 @@ object rxSortByForm: TrxSortByForm
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideBottom.Control = ButtonPanel1 AnchorSideBottom.Control = ButtonPanel1
Left = 6 Left = 6
Height = 21 Height = 22
Top = 342 Top = 335
Width = 155 Width = 151
Anchors = [akLeft, akBottom] Anchors = [akLeft, akBottom]
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'Case insensitive sort' Caption = 'Case insensitive sort'

View File

@ -31,13 +31,13 @@
unit rxsortby; unit rxsortby;
{$mode objfpc}{$H+} {$I rx.inc}
interface interface
uses uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs, Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, Buttons, ButtonPanel, db; StdCtrls, Buttons, ButtonPanel, rxdbgrid, db;
type type
@ -58,25 +58,23 @@ type
UpBtn: TBitBtn; UpBtn: TBitBtn;
procedure AddBtnClick(Sender: TObject); procedure AddBtnClick(Sender: TObject);
procedure DownBtnClick(Sender: TObject); procedure DownBtnClick(Sender: TObject);
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
procedure FormCreate(Sender: TObject); procedure FormCreate(Sender: TObject);
procedure ListBox1DblClick(Sender: TObject); procedure ListBox1DblClick(Sender: TObject);
procedure ListBox2DblClick(Sender: TObject); procedure ListBox2DblClick(Sender: TObject);
procedure RemoveBtnClick(Sender: TObject); procedure RemoveBtnClick(Sender: TObject);
procedure UpBtnClick(Sender: TObject); procedure UpBtnClick(Sender: TObject);
private private
OrderListTemp: TStringList;
OrderAsc:boolean;
public public
{ public declarations } { public declarations }
function Execute(adoTable : TDataSet; SortFieldNames:TStringList; var Asc:boolean):Boolean; function Execute(ADBGrid:TRxDBGrid; SortFieldNames:TStringList; var Asc:boolean):Boolean;
end; end;
var var
rxSortByForm: TrxSortByForm; rxSortByForm: TrxSortByForm;
implementation implementation
uses rxdconst; uses rxdconst, DBGrids;
{$R *.lfm} {$R *.lfm}
@ -85,29 +83,22 @@ uses rxdconst;
procedure TrxSortByForm.DownBtnClick(Sender: TObject); procedure TrxSortByForm.DownBtnClick(Sender: TObject);
var var
TmpField:String; TmpField:String;
Poz : Integer; C1:TObject;
Poz: Integer;
begin begin
if ListBox1.ItemIndex < ListBox1.Items.Count-1 Then if ListBox1.ItemIndex < ListBox1.Items.Count-1 Then
begin begin
Poz:=ListBox1.ItemIndex; Poz:=ListBox1.ItemIndex;
TmpField:=ListBox1.Items[Poz+1];
ListBox1.Items[Poz+1]:=ListBox1.Items[Poz];
ListBox1.Items[Poz]:=TmpField;
ListBox1.ItemIndex:=Poz+1;
end;
end;
procedure TrxSortByForm.FormClose(Sender: TObject; var CloseAction: TCloseAction TmpField:=ListBox1.Items[Poz+1];
); C1:=ListBox1.Items.Objects[Poz+1];
var
X:Integer; ListBox1.Items[Poz+1]:=ListBox1.Items[Poz];
begin ListBox1.Items.Objects[Poz+1]:=ListBox1.Items.Objects[Poz];
if ModalResult = mrOk then
begin ListBox1.Items[Poz]:=TmpField;
OrderAsc:=(ComboBox1.ItemIndex=0); ListBox1.Items.Objects[Poz]:=C1;
OrderListTemp.Clear; ListBox1.ItemIndex:=Poz+1;
for X:=0 To ListBox1.Items.Count-1 do
OrderListTemp.Add(ListBox1.Items[X]);
end; end;
end; end;
@ -143,7 +134,7 @@ procedure TrxSortByForm.AddBtnClick(Sender: TObject);
begin begin
if ListBox2.ItemIndex <> -1 Then if ListBox2.ItemIndex <> -1 Then
begin begin
ListBox1.Items.Add(ListBox2.Items.Strings[ListBox2.ItemIndex]); ListBox1.Items.Objects[ListBox1.Items.Add(ListBox2.Items[ListBox2.ItemIndex])]:=ListBox2.Items.Objects[ListBox2.ItemIndex];
ListBox2.Items.Delete(ListBox2.ItemIndex); ListBox2.Items.Delete(ListBox2.ItemIndex);
ListBox1.ItemIndex:=ListBox1.Items.Count-1; ListBox1.ItemIndex:=ListBox1.Items.Count-1;
end; end;
@ -153,7 +144,7 @@ procedure TrxSortByForm.RemoveBtnClick(Sender: TObject);
begin begin
if ListBox1.ItemIndex <> -1 Then if ListBox1.ItemIndex <> -1 Then
begin begin
ListBox2.Items.Add(ListBox1.Items.Strings[ListBox1.ItemIndex]); ListBox2.Items.Objects[ListBox2.Items.Add(ListBox1.Items[ListBox1.ItemIndex])]:=ListBox1.Items.Objects[ListBox1.ItemIndex];
ListBox1.Items.Delete(ListBox1.ItemIndex); ListBox1.Items.Delete(ListBox1.ItemIndex);
end; end;
end; end;
@ -162,61 +153,66 @@ procedure TrxSortByForm.UpBtnClick(Sender: TObject);
var var
TmpField:String; TmpField:String;
Poz : Integer; Poz : Integer;
C1:TObject;
begin begin
if ListBox1.ItemIndex > 0 Then if ListBox1.ItemIndex > 0 Then
begin begin
Poz:=ListBox1.ItemIndex; Poz:=ListBox1.ItemIndex;
TmpField:=ListBox1.Items[Poz-1]; TmpField:=ListBox1.Items[Poz-1];
C1:=ListBox1.Items.Objects[Poz-1];
ListBox1.Items[Poz-1]:=ListBox1.Items[Poz]; ListBox1.Items[Poz-1]:=ListBox1.Items[Poz];
ListBox1.Items.Objects[Poz-1]:=ListBox1.Items.Objects[Poz];
ListBox1.Items[Poz]:=TmpField; ListBox1.Items[Poz]:=TmpField;
ListBox1.Items.Objects[Poz]:=C1;
ListBox1.ItemIndex:=Poz-1; ListBox1.ItemIndex:=Poz-1;
end; end;
end; end;
function TrxSortByForm.Execute(adoTable : TDataSet; SortFieldNames: TStringList; var Asc:boolean): Boolean; function TrxSortByForm.Execute(ADBGrid: TRxDBGrid;
SortFieldNames: TStringList; var Asc: boolean): Boolean;
var var
X,P : Integer; i, j : Integer;
S : String; S : String;
SortFieldNamesTmp : TStringList; C:TColumn;
begin begin
Result:=False; Result:=False;
if not (Assigned(ADBGrid.DataSource) and Assigned(ADBGrid.DataSource.DataSet) and ADBGrid.DataSource.DataSet.Active) then exit;
ListBox1.Clear;
ListBox2.Clear;
if not Asc then if not Asc then
ComboBox1.ItemIndex:=1 ComboBox1.ItemIndex:=1
else else
ComboBox1.ItemIndex:=0; ComboBox1.ItemIndex:=0;
SortFieldNamesTmp:=TStringList.Create;
for X:=0 to adoTable.FieldDefs.Count-1 do
// If (NOT adoTable.FieldDefs[X].FieldClass.IsBlob) Then
SortFieldNamesTmp.Add(adoTable.FieldDefs.Items[X].Name);
if SortFieldNames.Count > 0 Then
begin
ListBox1.Clear;
for X:=0 To SortFieldNames.Count-1 Do
begin
S:=SortFieldNames.Strings[X];
ListBox1.Items.Add(S);
P:=SortFieldNamesTmp.IndexOF(SortFieldNames.Strings[X]);
if P > -1 then
SortFieldNamesTmp.Delete(P);
end;
end;
if SortFieldNamesTmp.Count > 0 then
begin
ListBox2.Clear;
for X:=0 To SortFieldNamesTmp.Count-1 do
ListBox2.Items.Add(SortFieldNamesTmp.Strings[X]);
end;
SortFieldNamesTmp.Free;
OrderListTemp:=SortFieldNames; for i:=0 to ADBGrid.Columns.Count-1 do
OrderAsc:=Asc; begin
C:=ADBGrid.Columns[i];
if SortFieldNames.IndexOf(C.Field.FieldName) > -1 then
ListBox1.Items.Objects[ListBox1.Items.Add(C.Title.Caption)]:=C
else
ListBox2.Items.Objects[ListBox2.Items.Add(C.Title.Caption)]:=C;
end;
if ShowModal = mrOK Then if ShowModal = mrOK Then
begin begin
Asc:=OrderAsc; Asc:= ComboBox1.ItemIndex = 0;
SortFieldNames.Clear;
for i:=0 to ListBox1.Items.Count-1 do
begin
C:=ListBox1.Items.Objects[i] as TColumn;
SortFieldNames.Add(C.FieldName);
end;
Result:=True; Result:=True;
end; end;
end; end;
end. end.