关于TDBGridEh的排序,对Asta的增强(0分)

  • 主题发起人 主题发起人 超级牛X
  • 开始时间 开始时间

超级牛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>{ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>{ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;EhLib v3.x &nbsp;Asta 2.x Asta 3.x &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br>{ &nbsp; Register object that sort data in TAstaClientDataset}<br>{ &nbsp; Register object that sort data in TAstaDataset &nbsp; &nbsp; &nbsp;}<br>{ &nbsp; &nbsp;Copyright (c) 2006, 2007 by Floyd.Chen &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>{ &nbsp; &nbsp;Floyd.Chen@gmail.com &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>{*******************************************************}<br><br>{*******************************************************}<br>{ Add this unit to 'uses' clause of any unit of your &nbsp; &nbsp;}<br>{ project to allow TDBGridEh to sort data in &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br>{ TAstaClientDataset automatically after sorting markers}<br>{ will be changed. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br>{ TAstaDataset automatically after sorting markers &nbsp; &nbsp; &nbsp;}<br>{ will be changed. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br>{*******************************************************}<br><br>unit EhLibAsta;<br><br>//{$I EhLib.Inc} &nbsp;//If you don't put this unit to the EhLib source path.<br><br>interface<br><br>uses<br> &nbsp;DbUtilsEh,DB, AstaDrv2, AstaClientDataset, DBGridEh;<br><br>implementation<br><br>uses Classes;<br><br>type<br> &nbsp;TAstaDatasetCrack = class(TAstaCustomDataset);<br><br>procedure SortDataInAstaDataSet(Grid: TCustomDBGridEh; DataSet: TAstaCustomDataset);<br>var<br> &nbsp;i: Integer;<br> &nbsp;FieldNames: array of string;<br> &nbsp;Descendings: array of Boolean;<br>begin<br> &nbsp;SetLength(FieldNames,Grid.SortMarkedColumns.Count);<br> &nbsp;SetLength(Descendings,Grid.SortMarkedColumns.Count);<br> &nbsp;for i := 0 to Grid.SortMarkedColumns.Count - 1 do<br> &nbsp;begin<br> &nbsp; &nbsp;FieldNames:=Grid.SortMarkedColumns.FieldName;<br> &nbsp; &nbsp;Descendings:=not (Grid.SortMarkedColumns.Title.SortMarker = smUpEh);<br> &nbsp;end;<br> &nbsp;DataSet.SortDataSetByFieldNames(FieldNames,Descendings);<br> &nbsp;SetLength(FieldNames,0);<br> &nbsp;SetLength(Descendings,0);<br>end;<br><br>type<br><br> &nbsp;TAstaSQLDatasetFeaturesEh = class(TSQLDatasetFeaturesEh)<br> &nbsp;public<br> &nbsp; &nbsp;procedure ApplySorting(Sender: TObject; DataSet: TDataSet; IsReopen: Boolean); override;<br> &nbsp;end;<br><br>//implementation<br><br>{ TAstaSQLDatasetFeaturesEh }<br><br>procedure TAstaSQLDatasetFeaturesEh.ApplySorting(Sender: TObject;<br> &nbsp;DataSet: TDataSet; IsReopen: Boolean);<br>begin<br> &nbsp;if Sender is TCustomDBGridEh then<br> &nbsp; &nbsp;if TCustomDBGridEh(Sender).SortLocal then<br> &nbsp; &nbsp; &nbsp;SortDataInAstaDataSet(TCustomDBGridEh(Sender), TAstaCustomDataset(DataSet))<br> &nbsp; &nbsp;else<br> &nbsp; &nbsp; &nbsp;inherited ApplySorting(Sender, DataSet, IsReopen);<br>end;<br><br>initialization<br> &nbsp;RegisterDatasetFeaturesEh(TAstaSQLDatasetFeaturesEh, TAstaDataset);<br> &nbsp;RegisterDatasetFeaturesEh(TAstaSQLDatasetFeaturesEh, TAstaClientDataset);<br>end.
 
后退
顶部