Solved

Delphi Grid Filter Assistance

Posted on 2013-01-11
3
637 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 32

Expert Comment

by:Ephraim Wangoya
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

696 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