dxMemData Filtre Sorunu

Delphi'de kod yazma ile ilgili sorularınızı bu foruma yazabilirsiniz.
Cevapla
Kullanıcı avatarı
adelphiforumz
Üye
Mesajlar: 602
Kayıt: 01 Nis 2008 05:38
Konum: İstanbul

dxMemData Filtre Sorunu

Mesaj gönderen adelphiforumz »

S.A.
dxMemData üzerinde filtre birden fazla field filtre etmek istiyorum fakat bir türlü olmadı
acaba nerde hata olabilir memdatada bulunan filter normal querydeki filter gibi çalışmıyormu

MemData.Filtered := False;
MemData.Filter := 'Ad = ' + #39 + sAd + #39 + ' and Soyad = ' + #39 + sSoyad + #39;
MemData.Filtered := True;

Teşekkürler
Ehil olmayanlara sabretmek ehil olanları parlatır.
Akıllı birisinden gelen cefa, bilgisizlerin vefasından iyidir.
Bilgiye ulaştı mı ayak, kanat olur
Biz insanı kıyafetiyle ağırlar bilgisiyle uğurlarız.
Mevlana
Kullanıcı avatarı
freeman35
Admin
Mesajlar: 2380
Kayıt: 12 Haz 2003 04:05
Konum: merkez camii yanı

Re: dxMemData Filtre Sorunu

Mesaj gönderen freeman35 »

MemData.Filter := 'Ad = ' + QuotedStr(sAd) + ' and Soyad = ' + QuotedStr(sSoyad); yazdığında anormalik yok. çalışmıyor !!! dan ne anlamalıyız?
ZAGOR TENAY TÜRK'tür... TÜRK kalacak...
Zoru başarırım, İmkansız zaman alır
FreeMan 35.5

Soru sormaya üşenmiyorsan, sorunun çözümünü yazmaya da üşenme !!!
Kullanıcı avatarı
adelphiforumz
Üye
Mesajlar: 602
Kayıt: 01 Nis 2008 05:38
Konum: İstanbul

Re: dxMemData Filtre Sorunu

Mesaj gönderen adelphiforumz »

Aşağıda yaptığım denemenin kodlarını ekledim
programda 3 buton var
"On Filter İle" olan çalışıyor
"Direkt Filter" olan çalışmıyor
"QuDirekt Filter" olan çalışmıyor

Kod: Tümünü seç

object Form1: TForm1
  Left = 0
  Top = 0
  Caption = 'Form1'
  ClientHeight = 334
  ClientWidth = 548
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object cxGrid1: TcxGrid
    Left = 96
    Top = 84
    Width = 271
    Height = 225
    TabOrder = 0
    object cxGrid1DBTableView1: TcxGridDBTableView
      Navigator.Buttons.CustomButtons = <>
      DataController.DataSource = DS
      DataController.Summary.DefaultGroupSummaryItems = <>
      DataController.Summary.FooterSummaryItems = <>
      DataController.Summary.SummaryGroups = <>
      object cxGrid1DBTableView1RecId: TcxGridDBColumn
        DataBinding.FieldName = 'RecId'
        Visible = False
      end
      object cxGrid1DBTableView1a: TcxGridDBColumn
        DataBinding.FieldName = 'a'
        Width = 85
      end
      object cxGrid1DBTableView1b: TcxGridDBColumn
        DataBinding.FieldName = 'b'
      end
    end
    object cxGrid1Level1: TcxGridLevel
      GridView = cxGrid1DBTableView1
    end
  end
  object Button1: TButton
    Left = 16
    Top = 26
    Width = 75
    Height = 25
    Caption = 'On Filter '#304'le'
    TabOrder = 1
    OnClick = Button1Click
  end
  object Edit1: TEdit
    Left = 16
    Top = 55
    Width = 75
    Height = 21
    BevelWidth = 2
    TabOrder = 2
    Text = '2'
  end
  object Button2: TButton
    Left = 202
    Top = 27
    Width = 123
    Height = 25
    Caption = 'Direkt Filter'
    TabOrder = 3
    OnClick = Button2Click
  end
  object Edit2: TEdit
    Left = 204
    Top = 58
    Width = 121
    Height = 21
    TabOrder = 4
    Text = 'b = '#39'2'#39
  end
  object Button3: TButton
    Left = 388
    Top = 26
    Width = 123
    Height = 25
    Caption = 'QuDirekt Filter'
    TabOrder = 5
    OnClick = Button3Click
  end
  object Edit3: TEdit
    Left = 390
    Top = 57
    Width = 121
    Height = 21
    TabOrder = 6
    Text = '2'
  end
  object MD: TdxMemData
    Active = True
    Indexes = <>
    Persistent.Data = {
      5665728FC2F5285C8FFE3F020000000A0000000100020061000A000000010002
      0062000101000000310101000000310101000000320101000000320101000000
      3300010100000034010100000034010100000035000101000000360101000000
      3601010000003701010000003201010000003801010000003201010000003901
      0100000033}
    SortOptions = []
    Left = 36
    Top = 136
    object MDa: TStringField
      FieldName = 'a'
      Size = 10
    end
    object MDb: TStringField
      FieldName = 'b'
      Size = 10
    end
  end
  object DS: TDataSource
    DataSet = MD
    Left = 30
    Top = 198
  end
end

Kod: Tümünü seç

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, cxGraphics, cxControls, cxLookAndFeels, cxLookAndFeelPainters, cxStyles, cxCustomData, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, dxmdaset, StdCtrls, cxGridLevel, cxGridCustomTableView, cxGridTableView,
  cxGridDBTableView, cxClasses, cxGridCustomView, cxGrid;

type
  TForm1 = class(TForm)
    MD: TdxMemData;
    DS: TDataSource;
    cxGrid1DBTableView1: TcxGridDBTableView;
    cxGrid1Level1: TcxGridLevel;
    cxGrid1: TcxGrid;
    MDa: TStringField;
    MDb: TStringField;
    cxGrid1DBTableView1RecId: TcxGridDBColumn;
    cxGrid1DBTableView1a: TcxGridDBColumn;
    cxGrid1DBTableView1b: TcxGridDBColumn;
    Button1: TButton;
    Edit1: TEdit;
    Button2: TButton;
    Edit2: TEdit;
    Button3: TButton;
    Edit3: TEdit;
    procedure MDFilterRecord(DataSet: TDataSet; var Accept: Boolean);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

var
  x : String;
procedure TForm1.Button1Click(Sender: TObject);
begin
  MD.OnFilterRecord := MDFilterRecord;
  MD.Filtered := False;
  x := Edit1.Text;
  MD.Filter := x;
  MD.Filtered := True;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  MD.Filtered := False;
  MD.Filter   := Edit2.Text;
  MD.Filtered := True;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  MD.Filtered := False;
  MD.Filter   := 'b=' + QuotedStr(Edit3.Text);
  MD.Filtered := True;
end;

procedure TForm1.MDFilterRecord(DataSet: TDataSet; var Accept: Boolean);
begin
  Accept := MD.FieldByName('b').AsString = x;
end;

end.
Ehil olmayanlara sabretmek ehil olanları parlatır.
Akıllı birisinden gelen cefa, bilgisizlerin vefasından iyidir.
Bilgiye ulaştı mı ayak, kanat olur
Biz insanı kıyafetiyle ağırlar bilgisiyle uğurlarız.
Mevlana
Kullanıcı avatarı
freeman35
Admin
Mesajlar: 2380
Kayıt: 12 Haz 2003 04:05
Konum: merkez camii yanı

Re: dxMemData Filtre Sorunu

Mesaj gönderen freeman35 »

adelphiforumz yazdı:procedure TForm1.MDFilterRecord(DataSet: TDataSet; var Accept: Boolean);
begin
Accept := MD.FieldByName('b').AsString = x;
end;
bu event in nasıl çalıştığını incele, deveex helplerinde açıklaması vardır muhtemelen.
Kolay gele
ZAGOR TENAY TÜRK'tür... TÜRK kalacak...
Zoru başarırım, İmkansız zaman alır
FreeMan 35.5

Soru sormaya üşenmiyorsan, sorunun çözümünü yazmaya da üşenme !!!
Kullanıcı avatarı
mucahityagmur
Üye
Mesajlar: 10
Kayıt: 07 Şub 2015 01:47

Re: dxMemData Filtre Sorunu

Mesaj gönderen mucahityagmur »

Hatırladığım kadarıyla tDxMemData'nın Filtreleme özelliği yoktu.
O yüzden 'runtime kodla' yapıyorum.

Kod: Tümünü seç

var dx1 : tDxMemData;
.....
Procedure Filtrele(arananADstring,arananSoyADstring : string);
begin
   dx1.ProgrammedFilter:=False; // ProgrammedFilter !
   dx1.Filtered:=False;
   dx1.FilterList.Clear;
   dx1.First;
   dx1.ProgrammedFilter:=TRUE;
  while not dx1.EOF do
   begin
     if (dx1.FieldByName('AD').AsString=arananADstring) and
        (dx1.FieldByName('SOYAD').AsString=arananSoyADstring) then
          dx1.FilterLis.Add(dx1.CurRec +1);
     dx1.Next;
   end;
  dx1.Filtered:=TRUE;
end;
//bir denemelisin.
Cevapla