0

I am working in Delphi, In a project, I do have a cxgrid, which contains master and a detail grid. let us assume, we have a master grid which has multiple lines, out of which few of the lines have detail grids. I have to search the text so that, if the text is not present in the master grid line but present in the respective detail grid of the same Master grid line, then in the filtered list, I can see the master grid line. (which does not have the text).

Please help me, in this regard.

thanks

vizz
  • 1
  • So, are you saying that the text you are looking for is stored in the detail rows and that you want to display only the master rows which have a detail row containing the text? – MartynA Oct 19 '18 at 19:10
  • I want to show the detail grid rows if the text is not present in the master row. if it is possible to show those grid rows without master rows, it is fine. But I think we can not show only detail grid rows without master rows. – vizz Oct 20 '18 at 17:05
  • @vizz That is correct. The master row is a parent in a DevEx cxGrid. You can't see the detail for a master that doesn't show. How would they look in the Grid anyway? (a little strange) – Freddie Bell Oct 20 '18 at 17:11
  • there are two cases: 1. if the text is present in (both master and detail grid) OR (Text is present in only master grid) : with the help of this :(cxGrid1TableView1.DataController.Filter.Root.AddItemList(fboOr) .AddItem(cxGrid1TableView1ColumnDesc, foLike, '%'+ss+'%', '%'+ss+'%') ) function i can add that master row in the filtered grid, BUT if that text is not present in the master grid but present its detail grid, then i am unable to add that master or detail grid in the filtered grid. – vizz Oct 20 '18 at 17:31
  • @vizz, if I understand correctly, your query should take into account the data of your dataset and not the data present in the views. This way you can apply a filter in the view master based on filters applied in both DATASETS – AnselmoMS Oct 20 '18 at 22:17
  • @AnselmoMS, thanks for replying, can you help me with an example or a little more explanation, if possible? – vizz Oct 20 '18 at 22:19
  • Assuming you have a master `dataset` that contains a list of fathers and another detail dataset with a list of children. You should filter both datasets by looking for the father name and getting the IDs from the Master dataset. Finnaly, use these IDs to apply a filter on Master view of `cxGrid`. – AnselmoMS Oct 20 '18 at 22:33

1 Answers1

0

devexpress don't have a ready made function for that. you have to make a work around. one simple way is to create an invisible column in your master table that will contain all searchable text from the detail. if you it like that you then you can use this function :

procedure FilterAll(A_vDBTable: TcxGridDBTableView; ASearchString: string);
var
  AView: TcxGridDBTableView;
  I: Integer;
  s: string;
begin

  AView := A_vDBTable;

  AView.DataController.Filter.Clear;
  AView.DataController.Filter.Root.Clear;
  AView.DataController.Filter.Root.BoolOperatorKind := fboOr;

  if ASearchString = '' then
  begin
    Exit;
  end;


  s := '%' + ASearchString + '%';
  for I := 0 to AView.ColumnCount - 1 do
  begin
    AView.DataController.Filter.Root.AddItem(AView.Columns[I],foLike,s,s);
  end;
  AView.DataController.Filter.Active := True;
end;
Ago
  • 755
  • 7
  • 28