Arsip: [HELP] SORTING DBGRID-INTERBASE

 
user image
more 8 years ago

vahnkrist

Permisi mau bertanya melakukan sorting records DBGrid dengan clicking di column title, tapi menggunakan Interbase set database. ada yang tahu? thanks for ur answer.... :)
user image
more 8 years ago

halimanh

Ini adalah tutorial sorting dbgrid pake ado, kalo pake interbase tinggal disesuaikan. http://delphi.about.com/od/usedbvcl/l/aa042203a.htm
user image
more 8 years ago

vahnkrist

disesuaikannya gimana? di tuker IBdataset(IBQuery,IBtable) ADODatasetnya ??? sorry nda mudeng...masih newbie :)
user image
more 8 years ago

halimanh

iya. Dan kalo propery/methodnya beda tinggal disesuaikan. saya nggak pake interbase, dan nggak install interbase servernya, jadi nggak bisa liat.
user image
more 8 years ago

vahnkrist

kyk ga kenal identifier "Sort".... :( kumaha iyeuh ey...owalah. sy pake Delphi 7 + Interbase 6.5 (komponen DBnya IBdatabase, IBTransaction, IBquery, DataSource)<<< dalam form data module bukan frm barang cuman tggal sortir doang.....meni hese ey diteang2 te :( [/code]
user image
more 8 years ago

halimanh

Kalo nggak ada sortnya, yah nggak bisa pake itu. Ada lagi post disini http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_11771698.html
user image
more 8 years ago

vahnkrist

walah jgn expert exchange please...ga bisa bukanya :(
user image
more 8 years ago

halimanh

Dari expert exchange Ok, I did some testing. If you have some higher versions of Delphi, you can use TClientDataSet. Below is my test case: 1. Drop TIBDatabase, TIBTransaction, TIBDataSet, TClientDataSet, TDataSource, and TDBGrid on a form. 2. Set TIBDatabase, and TIBTransaction properties so that you can connect the database. 3. Set TIBDataSet's SelectSQL property to get your data. 4. Right click ClientDataSet1 and select Assign Local data from the menu. Select IBDataSet1 from the list. (There shouldn't be more, anyway :-)). 5. Eventually, specify FileName for the local file. 6. In my case, things were somewhat slow, but see my notes below. 7. Assign DataSource1's Dataset to ClientDataSet1 and finally, set DBGrid's DataSource to ClientDataSet1. 8. Write an event handler to DBGrid1's OnTitleClick event: procedure TForm1.DBGrid1TitleClick(Column: TColumn); begin ClientDataSet1.IndexFieldNames := Column.Title.Caption; end; That's all. Tested on some 40,000 records table (The table had 20 Columns, mostly numeric (double precision)). The response time was good (always less than 1 sec, obviously 200-300 msec). Tested with IB 6, D 5 Ent, Pentium II 300 MHz / 128 MB.
user image
more 8 years ago

hendrang67

@vahnkrist: kyk ga kenal identifier "Sort".... :( kumaha iyeuh ey...owalah. sy pake Delphi 7 + Interbase 6.5 (komponen DBnya IBdatabase, IBTransaction, IBquery, DataSource)<<< dalam form data module bukan frm barang cuman tggal sortir doang.....meni hese ey diteang2 te :( [/code]
Untuk sort kalau pakai IBTable, isi indexfieldnames nya sesuai dgn field yg akan disort, kalau kalau pakai IBQuery lakukan query ulang. Contoh : Pakai TIBTable procedure TForm1.DBGrid1TitleClick(Column: TColumn); begin IBTable1.IndexFieldNames:= Column.FieldName; //IBTable1.IndexName:= Column.FieldName; // Kalau code di atas tdk bisa, coba aktifkan code ini end; Pakai TIBQuery procedure TForm1.DBGrid1TitleClick(Column: TColumn); var FldName: String; begin FldName:= Column.FieldName; IBQuery1.Close; IBQuery1.SQL.Text:= 'Select * from noperk order by '+ fldName; IBQuery1.ExecSql; end; Saya juga tidak pakai Interbase jadi tdk bisa test.
user image
more 8 years ago

hendrang67

@hendrang67: [quote:6d6bdc2cc3="vahnkrist"] kyk ga kenal identifier "Sort".... :( kumaha iyeuh ey...owalah. sy pake Delphi 7 + Interbase 6.5 (komponen DBnya IBdatabase, IBTransaction, IBquery, DataSource)<<< dalam form data module bukan frm barang cuman tggal sortir doang.....meni hese ey diteang2 te :( [/code][/quote:6d6bdc2cc3] Untuk sort kalau pakai IBTable, isi indexfieldnames nya sesuai dgn field yg akan disort, kalau kalau pakai IBQuery lakukan query ulang. Contoh : Pakai TIBTable procedure TForm1.DBGrid1TitleClick(Column: TColumn); begin IBTable1.IndexFieldNames:= Column.FieldName; //IBTable1.IndexName:= Column.FieldName; // Kalau code di atas tdk bisa, coba aktifkan code ini end; Pakai TIBQuery procedure TForm1.DBGrid1TitleClick(Column: TColumn); var FldName: String; begin FldName:= Column.FieldName; IBQuery1.Close; IBQuery1.SQL.Text:= 'Select from noperk order by '+ fldName; IBQuery1.ExecSql; end; Saya juga tidak pakai Interbase jadi tdk bisa test.
Pakai TIBQuery procedure TForm1.DBGrid1TitleClick(Column: TColumn); var FldName: String; begin FldName:= Column.FieldName; IBQuery1.Close; IBQuery1.SQL.Text:= 'Select from <nama file> order by '+ fldName; IBQuery1.ExecSql; end;
more ...
  • Pages:
  • 1
  • 2
Share to
Local Business Directory, Search Engine Submission & SEO Tools FreeWebSubmission.com SonicRun.com