超
超级牛X
Unregistered / Unconfirmed
GUEST, unregistred user!
为EhLib扩充了一个单元,放在EhLib源代码目录下面就可以了<br>http://hi.baidu.com/floyd/blog/item/acd0d507650b86cd7a894788.html<br>TDBGridEh组件的[OptionsEh]中的 dgAutoSortMarking 属性设置为 True;<br>TDBGridEh组件的SortLocal属性设置为 True;<br>双击Columns,在每一个(TDBGridColumnsEh)的[Title]的 TitleButton 属性设置为 True; <br>在 uses 子句中加上 EhLibBDE,或者EhLibAdo,或者EhLibCDS,或者EhLibAsta单元。<br><br>???可是找遍了EhLib的文件夹,都没有EhLibAsta这个单元啊?<br><br>Floyd奸笑着说:当然没有,这是我自己写的嘛!<br><br>下面是源代码<br>//一定要修改的话,保留我的个人信息啊。<br>{*******************************************************}<br>{ }<br>{ EhLib v3.x Asta 2.x Asta 3.x }<br>{ Register object that sort data in TAstaClientDataset}<br>{ Register object that sort data in TAstaDataset }<br>{ Copyright (c) 2006, 2007 by Floyd.Chen }<br>{ Floyd.Chen@gmail.com }<br>{*******************************************************}<br><br>{*******************************************************}<br>{ Add this unit to 'uses' clause of any unit of your }<br>{ project to allow TDBGridEh to sort data in }<br>{ TAstaClientDataset automatically after sorting markers}<br>{ will be changed. }<br>{ TAstaDataset automatically after sorting markers }<br>{ will be changed. }<br>{*******************************************************}<br><br>unit EhLibAsta;<br><br>//{$I EhLib.Inc} //If you don't put this unit to the EhLib source path.<br><br>interface<br><br>uses<br> DbUtilsEh,DB, AstaDrv2, AstaClientDataset, DBGridEh;<br><br>implementation<br><br>uses Classes;<br><br>type<br> TAstaDatasetCrack = class(TAstaCustomDataset);<br><br>procedure SortDataInAstaDataSet(Grid: TCustomDBGridEh; DataSet: TAstaCustomDataset);<br>var<br> i: Integer;<br> FieldNames: array of string;<br> Descendings: array of Boolean;<br>begin<br> SetLength(FieldNames,Grid.SortMarkedColumns.Count);<br> SetLength(Descendings,Grid.SortMarkedColumns.Count);<br> for i := 0 to Grid.SortMarkedColumns.Count - 1 do<br> begin<br> FieldNames:=Grid.SortMarkedColumns.FieldName;<br> Descendings:=not (Grid.SortMarkedColumns.Title.SortMarker = smUpEh);<br> end;<br> DataSet.SortDataSetByFieldNames(FieldNames,Descendings);<br> SetLength(FieldNames,0);<br> SetLength(Descendings,0);<br>end;<br><br>type<br><br> TAstaSQLDatasetFeaturesEh = class(TSQLDatasetFeaturesEh)<br> public<br> procedure ApplySorting(Sender: TObject; DataSet: TDataSet; IsReopen: Boolean); override;<br> end;<br><br>//implementation<br><br>{ TAstaSQLDatasetFeaturesEh }<br><br>procedure TAstaSQLDatasetFeaturesEh.ApplySorting(Sender: TObject;<br> DataSet: TDataSet; IsReopen: Boolean);<br>begin<br> if Sender is TCustomDBGridEh then<br> if TCustomDBGridEh(Sender).SortLocal then<br> SortDataInAstaDataSet(TCustomDBGridEh(Sender), TAstaCustomDataset(DataSet))<br> else<br> inherited ApplySorting(Sender, DataSet, IsReopen);<br>end;<br><br>initialization<br> RegisterDatasetFeaturesEh(TAstaSQLDatasetFeaturesEh, TAstaDataset);<br> RegisterDatasetFeaturesEh(TAstaSQLDatasetFeaturesEh, TAstaClientDataset);<br>end.