Incremental filtering

Hi.

I need to produce an incremental filter that is defined by 3 TEdit components.

procedure TForm2.Button1Click(Sender: TObject); begin
with advstringgrid1.Filter.Add do begin
condition := '>50'; column := 1;
end;
advstringgrid1.ApplyFilter;
with advstringgrid1.Filter.Add do begin
condition := '<75'; column := 1;
end;
advstringgrid1.ApplyFilter;
advstringgrid1.RemoveLastFilter;
end;

I found this example in the manual, but dont know how to convert it into C++ syntax since C++ does not have "with" statement?


Please use:

TFilterData *fd;

fd = AdvStringGrid.Filter.Add();
fd->Condition = ">50";
fd->Column = 1;
AdvStringGrid->ApplyFilter();
Bruno Fierens2010-07-05 09:19:58

Thanks

Filters dont work when using TDBAdvGrid. It's ok when using AdvStringGrid, but if I use TDBAdvGrid result is almost never correct, and I've tried like everything: calling NarrowDown, AutoDropDown Filters, Conditional filtering. Everything like described in the manual and demos.

Usually DBGrid is returning the correct number of rows but the data (rows) are not updated in the grid. For example, if a result of the filtering is 9 records then DBGrid will show me the first 9 rows in the grid and not the 9 rows that I wanted to see (real result).

Did you set grid.PageMode = false ?  This is required when you want to use the grid's internal filtering as opposed to performing your filter on dataset level.

Now it's ok, but there is another problem. After I get results I want to doubleclick one of the rows and change the columns, but I cant do that since my dataset cursor is not avaible. How to edit rows if PageMode is false?

I need to filter records so I can find them faster, but when I find them I need to edit them.

If you need editing & filtering, please perform the filtering on dataset level. For editing, PageMode must be set true, so you can use a SQL query to define the filter. 

Well, i can't do filtering on dataset level since I use "briefcase" db client approach. Too bad that PageMode restricts so many usefull features like grouping, filtering etc...