Skip to content

DataGrid: expose row index#15909

Merged
maxkatz6 merged 2 commits into
AvaloniaUI:masterfrom
rabbitism:grid
Jun 6, 2024
Merged

DataGrid: expose row index#15909
maxkatz6 merged 2 commits into
AvaloniaUI:masterfrom
rabbitism:grid

Conversation

@rabbitism

@rabbitism rabbitism commented Jun 4, 2024

Copy link
Copy Markdown
Contributor

What does the pull request do?

Make DataGridRow.Index public get-able.

What is the current behavior?

It's hard to show row number.

What is the updated/expected behavior with this PR?

User can use below binding to show row index.

<DataGridTextColumn Header=" " Binding="{Binding $parent[DataGridRow].Index}" Width="60" x:DataType="local:Country" />

8fc15485cb3ce96686af2e6f0b845ee

How was the solution implemented (if it's not obvious)?

Checklist

Breaking changes

I think no.

Obsoletions / Deprecations

GetIndex method is obsoleted, should be replaced by Index property

Fixed issues

Comment thread src/Avalonia.Controls.DataGrid/DataGridRow.cs
@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 11.2.999-cibuild0048779-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@cla-avalonia

cla-avalonia commented Jun 4, 2024

Copy link
Copy Markdown
Collaborator
  • All contributors have signed the CLA.

@rabbitism

Copy link
Copy Markdown
Contributor Author

@cla-avalonia agree

@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 11.2.999-cibuild0048787-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@stevemonaco

Copy link
Copy Markdown
Contributor

What are the performance implications if you insert or remove the first row of a 100k row DataGrid? Does this cause 100k PropertyChanged events for Index? Or only for the rows that are presently materialized via virtualization?

@maxkatz6

maxkatz6 commented Jun 5, 2024

Copy link
Copy Markdown
Member

It should affect only rows that are currently materialized.

@maxkatz6
maxkatz6 added this pull request to the merge queue Jun 6, 2024
Merged via the queue into AvaloniaUI:master with commit 7413434 Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants