Solved

Delphi Grid Filter Assistance

Posted on 2013-01-11
3
616 Views
Last Modified: 2013-01-15
I have a grid that needs a filter that I just can't seem to figure out.

I need it to filter to show records that are either (JobSchedule > 0) OR (PercentComplete < 1) which I have working BUT users sometimes add a criteria to narrow the grid down to a specific JobNumber. When they try to filter to a specific job record and the above filter is applied, it adds the 3rd criteria as an OR when I need it to be AND.  Basically if the user adds any new criteria to filter down to, such as Job#222, I need it to ONLY show Job#222.

Here is the current filter:

       with gvMilling.DataController.Filter do begin
          Root.Clear;
          Root.BoolOperatorKind := fboOR;
          Root.AddItem(gvMillingJobSchedule,foGreaterEqual, '0', 'Department Start Range');
          Root.AddItem(gvMillingMil_Total_PercentComplete, foLess, '1', '100%');
          Active := True;
          end;

Open in new window

0
Comment
Question by:Bianca
3 Comments
 
LVL 32

Expert Comment

by:ewangoya
ID: 38768363
try this way
var
  AItemList: TcxFilterCriteriaItemList;
......
with gvMilling.DataController.Filter do begin
   Root.Clear;
   AItemList := Root.AddItemList(fboOr);
   AItemList.AddItem(gvMillingJobSchedule,foGreaterEqual, '0', 'Department Start Range');
   AItemList.AddItem(gvMillingMil_Total_PercentComplete, foLess, '1', '100%');
   //your new filter, user filter
   Root.AddItem(SelectedCol, foLess, 1000, '1000');
   Active := True;
end;

Open in new window

0
 

Author Comment

by:Bianca
ID: 38768371
That would work IF I knew what that 3rd filter was. It could be JobNumber, JobLocation, Contractor, etc. Is there a way to do this?
0
 
LVL 37

Accepted Solution

by:
Geert Gruwez earned 500 total points
ID: 38769111
have you tried nesting the filter and setting the main level to AND (not or)

- AND ( (JobSchedule > 0) OR (PercentComplete < 1))
- AND (user filter)

the user filter you give a default value which doesn't filter anything, like %
the user can then click the specific filter to narrow down.

they usually don't know that the "filter" word is also a button to add conditions in the filter box.

sample:

procedure TfrmSample.btnSetFilterClick(Sender: TObject);
var fR: TcxDataFilterCriteria;
  fL1, fL2: TcxFilterCriteriaItemList;
begin
  fR := gvMilling.DataController.Filter ;
  fR.Root.Clear;
  fR.Root.BoolOperatorKind := fboAnd;
  fL1 := fR.Root.AddItemList(fboOr);
  fR.AddItem(fL1, gvMillingJobSchedule,foGreaterEqual, '0', 'Department Start Range');
  fR.AddItem(fL1, gvMillingMil_Total_PercentComplete, foLess, '1', '100%');
  fL2 := fR.Root.AddItemList(fBoAnd);
  fR.AddItem(fL2, gvMillingJobNumber, foLike, '%', 'Any');
  fR.AddItem(fL2, gvMillingJobLocation, foLike, '%', 'Any');
  fR.AddItem(fL2, gvMillingContractor, foLike, '%', 'Any');
  fR.Active := true;
end;

Open in new window

0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Best Firemonkey component pack 1 104
How to debug For loops? 3 49
Firemonkey android show image from resource ? 1 42
MS Access from Delphi 31 28
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question