TAdvStringGrid filter only some columns

When I use the FilterDropdownAuto option in TAdvStringGrid all the columns are filtered. They all get a filterbutton, except the Fixedcolumnswhen the FilterNormalCellsOnly option is switched on.
How can I achieve that only certain columns get a filterbutton?
I was hoping there was an option for the TGridColumnItem that could achieve this, but if there is I can't find it. Can you tell me what I can do?

Second question (please answer the one above also):
When I search in TAdvStringGrid with the searchfooter and the SearchType stNarrowDown most of the rows disappear. That's fine. Bu t how do I get them back after I close the SearchFooter? I tried UnHideRowsAll, but then I get an error.

You can use the OnGetColumnFilter() event and return an empty filter condition list for columns where you do not want the filter dropdown.


This code removes the filter on column 2:

procedure TForm1.AdvStringGrid1GetColumnFilter(Sender: TObject; Column: Integer;
  Filter: TStrings);
begin
  if column = 2 then
    Filter.Clear;
end;

1 Like

Works great, thank you.

My second question was:
When I search in
TAdvStringGrid with the searchfooter and the SearchType stNarrowDown
most of the rows disappear. That's fine. Bu t how do I get them back
after I close the SearchFooter? I tried UnHideRowsAll, but then I get an
error.
I hope you can answer this one too.

You can do grid.NarrowDown('');  to undo a previous narrow down function.

Thank you.

One last thing, which I think must be a bug:
When I use MoveColumn(From, To) the columns are moved, but the sizes of the columns stay the same. In other words: it look like only the content of the columns moves, not the column itself.

I cannot reproduce such issue.

Test code:

procedure TForm3.FormCreate(Sender: TObject);
begin
  advstringgrid1.LinearFill(false);
  advstringgrid1.ColWidths[2] := 30;
  advstringgrid1.MoveColumn(2,4);
end;

The result is that column 4 will have a width of 30px.
How exactly can this problem be reproduced with the latest version of TAdvStringGrid?

I forgot to mention that I use a TAdvColumnGrid. Maybe that one works differently than the original TAdvStringGrid.
To test it I put a grid on a Form with 10 columns, the first one is fixed. The first Row is also fixed.
Column 2 has a width of 40, column 3 has a width of 100, column 5 has a width of 150.
I placed a button under that with only this code in the OnClick (CG is the TAdvColumnGrid):


CG.MoveColumn(2,5);


Column 2 is now what used to be column 3, but still has a width of 40.
If you can't reproduce it, it might be due to a setting in the grid. I can send you the sample program if you like.

I cannot reproduce this.

Test code:
procedure TForm1.FormCreate(Sender: TObject);
begin
  advcolumngrid1.ColCount := 10;
  advcolumngrid1.Columns[3].Width := 40;
  advcolumngrid1.Columns[2].Width := 24;
  advcolumngrid1.MoveColumn(2,5);
end;

Do you use the latest version of the component?

Yes, I use TMS Component Pack 8.5.7.0.
The grid I use is much more complicated than the one you use I think.
Can I send you the samplecode? I can also paste the .pas and .dfm here, but the .dfm is rather big.

Please try to isolate this. When sending sample source code, please contact us by email.

I sent an E-mail with the option provided on the website.
The code is only 1 line, the grid is the one I have the problem with.