Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Delphi Grid Filter Assistance

Posted on 2013-01-11
3
Medium Priority
?
710 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 38

Accepted Solution

by:
Geert Gruwez earned 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

618 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