RealToDisplay works fine when sorting the entire grid.
After filtering the remaining rows do have wrong RealToDisplay results…
Filtered rows keep the RealToDisplay number they had before filtering.
RealToDisplay works fine when sorting the entire grid.
After filtering the remaining rows do have wrong RealToDisplay results…
Filtered rows keep the RealToDisplay number they had before filtering.
Hi,
I’ve looked into this issue and fixed it. Next version of TMS FNC UI Pack addresses the issue, thanks for pointing out!.
Would you also get the alternating row colors issue fixed?
This should already be handled.
Alternating row colors are not working with filtered grid data.
I am using code like this snipped:
procedure TfrmGridFilter.GridGetCellLayout(Sender: TObject; ACell: TTMSFNCDataGridCell);
begin
if ACell.Row>0 then
begin
if (ACell.Row mod 2)=0 then
begin
ACell.Layout.Fill.Color:=clYellow;
end
else
begin
ACell.Layout.Fill.Color:=clBlue;
end;
end;
end;
Hi,
The row index remains the same even though you filter or hide rows.
When testing I found out after sorting:
Grid.Cells[AColumn,ARow]:=’Test’ writes in DisplayRow not in RealRow.
That causes big damage in the grid row data…
Yes that’s by design, sorting only moves the data, but the indexing remains the same. If you want to find out where the original row is located you can use:
TMSFNCDataGrid1.Cells[0, TMSFNCDataGrid1.RealToDisplayRow(3)] := 'Test';
RealToDisplayRow(ARow) is an unknown function in TMSFNCDataGrid (or am I missing classes)?
Woops, we have exposed this, but this hasn’t made the release yet, pleas use
TMSFNCDataGrid1.Root.RealToDisplayRow(3)
It seems I have a lot more under control now - except sorting filtered rows.
In that case DispRow is wrong…
Correct, this is a fix that’s still needs to be released. filtering didn’t properly adapt the display index for the rows.
Issue is still not fixed in latest version…
(I can not deliver apps to customers)
Can you provide a simple test case, what you expect and which code you are using so we can investigate?
It is easy to explain:
The OnCellClick event has a parameter ARow which is the DispRow.
In that event I debugged the DispRow=ARow=54:
Example: After sorting a Column has f. e. Data=B, RealRow=59 and a DispRow=54
Grid.Cells[0,54]:='Test' works fine
Now I put a filter on the grid and scroll to Data=B
Event OnCellClick still outputs DispRow as 54 - but Grid.Root.RealToDisplay(59) outputs DispRow as 20.
Even Grid.Cells[0,54]:='Test' still works?? - Cells[] works with DispRow?
Problem:
Event OnCellClick should in my opinion also output DispRow as 20.
Grid.Cells[0,20]:='Test' should write in RealRow 54
To make it short:
After Filtering DispRow and RealRow are the same…
OnCellClick and RealToDisplay deliver different DispRows…
Cells[]:=’Test’ now works with RealRow
I’m able to reproduce the issue, the whole mapping system is currently limited to sorting, moving row data, filtering & hiding rows actually doesn’t manipulate the row orders, but this makes it confusing. I’ll go back to the original implementation and will properly look at it as soon as possible. Thanks for the feedback!
ok, I am a bit under pressure because my customers are waiting for updates….
Let me walk through what's happening and what we've shipped to address it.
The grid internally uses three different row index spaces, and the API didn't expose all three clearly:
| Space | Meaning | Used by |
|---|---|---|
| RealRow | Physical row in the data store (pre-sort) | The dataset / adapter layer |
| DispRow | Index after sort/reorder, in [0..RowCount-1] |
Cells[], OnCellClick.ARow, hit-testing, selection, scroll — everything internal |
| VisualRow | 0-based index in the rendered output (sort + filter + hidden applied) | The new API in 7.1.2.2 |
In your example after sort+filter:
OnCellClick.ARow = 54 → that's the DispRow of the clicked cell. The render loop iterates DispRow indices and skips filtered ones during paint, but the DispRow of each visible cell doesn't get compacted.Cells[0, 54] := 'Test' works because Cells[] is also keyed by DispRow — same coordinate space as the event.We reverted the change in 7.1.2.1 that made RealToDisplayRow / DisplayToRealRow filter-aware — it conflicted with OnCellClick, Cells[], hit-testing, and selection, all of which work in DispRow space. Those two methods are now back to sort-only mapping, consistent with the rest of the grid.
The "visible-slot" mapping you wanted is now on four new methods:
function RealToVisualRow(ARow: Integer): Integer;
function VisualToRealRow(AVisualRow: Integer): Integer;
function RealToVisualColumn(AColumn: Integer): Integer;
function VisualToRealColumn(AVisualColumn: Integer): Integer;
Behavior:
Sort + filter + hidden applied. Returns -1 if the row/column is filtered or hidden.
Fixed top/left rows and columns map identity.
Fixed bottom/right rows and columns shift past the visible central count.
procedure TForm1.GridCellClick(Sender: TObject; AColumn, ARow: Integer);
var
RealRow, VisualRow: Integer;
begin
// ARow is the DispRow, e.g. 54
RealRow := Grid.DisplayToRealRow(ARow); // 59 — physical row
VisualRow := Grid.RealToVisualRow(RealRow); // 20 — on-screen slot
// Writing to the clicked cell — uses DispRow (the event's ARow):
Grid.Cells[0, ARow] := 'Test';
// Writing to "the cell currently at visible row 20":
Grid.Cells[0, Grid.RealToDisplayRow(Grid.VisualToRealRow(20))] := 'Test';
end;
OnCellClick.ARow to be the VisualRow?That would silently break every existing handler that uses ARow with Cells[], MoveRow, SelectCell, IsRowFiltered, etc. — all of those expect DispRow. Adding RealToVisualRow / VisualToRealRow was the additive, non-breaking path. If there's enough demand we can add an OnCellClickEx event later that passes the visual row alongside.
Both row and column variants will be available in v7.1.2.2 (TMS FNC UI Pack).
Thanks a lot - works…
Thanks for the feedback