FNCDataGrid AfterFilter event

Hi,

in documentation you wrote that on the FNCDataGrid OnAfterApplyFilter event you can cast the sender object to a TTMSFNCDataGrid object but it seems to be an error because the object is of type TTMSFNCDataGridRenderer.

procedure TForm1.TMSFNCDataGrid1AfterApplyFilter(Sender: TObject; AColumn: Integer; ACondition: string);
var
  Grid: TTMSFNCDataGrid;
  Total, Visible: Integer;
begin
  Grid := Sender as TTMSFNCDataGrid; // <- ERROR here
  Total   := Grid.RowCount - Grid.FixedRowCount;
  Visible := Grid.VisibleRowCount;
...

Also, on FNCDataGrid, if I enable the count of records as in

TMSFNCDataGrid1.ColumnCalculations[1, 'COUNT'] := [CreateNormalColumnCalculation(gcmCount)];

TMSFNCDataGrid1.UpdateCalculations;

the result is wrong: on column 1 I see 611 but the records in table are 612 and I have no filters. On the other side, OnAfterApplyFilter grid the “Total” is the right one (612), but if I play with grouping and de-grouping columns sometimes the footer changes to 612.

All components are in the latest version avalaible.

Regards.

Sergio

Thanks for pointing that out, we’ll fix the documentation. About the calculations, did you apply this to one of our demos? Can you maybe provide some more insight or a small sample demonstrating the issue?

Hi,

a simple case: add the code

var
  grid: TTMSFNCDataGridRenderer;

begin
  grid := (sender as TTMSFNCDataGridRenderer);
  var LTotal: integer := Grid.RowCount - Grid.FixedRowCount;
  var LVisible: integer := Grid.VisibleRowCount;
  showmessage(LVisible.ToString + ' on ' + LTotal.ToString);

to your FilterRow sample.

If you filter for 120 hp, you see only 6 rows on the grid (Audi, BMW and Chrysler), so I expect to have 6 (visible) on 112 (total), but you have as result 139 on 152 when the data rows on the .csv file are 112…

The count error of my first message was on a test form I’m working on and I need some time to create a working sample without my data in it because it uses a PostgreSQL database. So I’ll try to use a local dataset to duplicate the issue.

Regards.

Sergio

The amount of visible rows includes node & summary rows.

You can use this code:

procedure TForm130.TMSFNCDataGrid1AfterApplyFilter(Sender: TObject;
  AColumn: Integer; ACondition: string);
var
  grid: TTMSFNCDataGridRenderer;
  I: Integer;

begin
  grid := (sender as TTMSFNCDataGridRenderer);
  var K: Integer := 0;
  for I := TMSFNCDataGrid1.FixedRowCount to TMSFNCDataGrid1.RowCount - 1 do
  begin
    if TMSFNCDataGrid1.IsRowNormal(i) and not TMSFNCDataGrid1.IsRowFiltered(i) then
      Inc(K);
  end;

  TTMSFNCUtils.Log('Filtered Rows: ' + K.ToString);
end;

Here I have a fresh grid without nodes and summaries. But It says 90 rows…

I tested another demo with the code snippet:

Ok, I’ve corrected my AfterApplyFilter (my bad I corrected the wrong grid :frowning: and not this one) and now it works.

I’ll prepare a sample ASAP for the record count.

Regards!

1 Like

Hi, it seems to be the related to FixedBottomRowCount.

On the form OnCreate I put

  TMSFNCDataGrid1.FixedBottomRowCount := 1;
  TMSFNCDataGrid1.ColumnCalculations[1, 'COUNT'] := [CreateNormalColumnCalculation(gcmCount)];
  TMSFNCDataGrid1.UpdateCalculations;

to have the total on last row.

Running the app I have 611 as total rows (but I have 612 customers). If I change the FixedBottomRowCount to 2, I have 610 as total rows.

On the Group event of the grid I have also a CreateGroupColumnCalculation, and it shows the right values.

It seems also that not using the data adapter (like it’s in my applicatioon) but reading your cars.csv as a sample, it shows 112 that is the right count for the rows of the csv file.

How can I have the right count on the footer?

Thanks a lot in advance.

Sergio

You mention you have a dataset connected, can you scroll to all rows? Note that FixedBottomRowCount needs to be set before enabling the dataset.

You’re right! I’ve changed the setting and put it before opening the dataset and it works correctly.

One last question: will you implement a “global” search valid for all values in every column of the row or it’s a thing that must be implemented programmatically?

And… thank you for the solution!

Sergio

Hi,

Check out the Find() methods which are grid wide.

Hi,

have you a link for specific and extended Find documentation or samples?

Here, you can see a list of methods. TTMSFNCDataGridData - TMS FNC UI Pack

There are references to Find

and here is a topic using the find function to select a cell:

Thank you Pieter, I’ll play with the code to see what I can do.

Sergio

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.