Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(module:table): set selectedRows exception #1148

Merged
merged 2 commits into from
Feb 20, 2021
Merged

fix(module:table): set selectedRows exception #1148

merged 2 commits into from
Feb 20, 2021

Conversation

qinhuaihe
Copy link

馃 This is a ...

  • New feature
  • Bug fix
  • Site / documentation update
  • Demo update
  • Component style update
  • Bundle size optimization
  • Performance optimization
  • Refactoring
  • Code style optimization
  • Test Case
  • Branch merge
  • Other (about what?)

馃敆 Related issue link

馃挕 Background and solution

<Modal Visible="false">
    <Table SelectedRows="SelectedRows">...</Table>
</Modal>

Setting SelectedRows before table rendered leads to a NullReferenceException:
select_rows_exception

馃摑 Changelog

Language Changelog
馃嚭馃嚫 English
馃嚚馃嚦 Chinese

鈽戯笍 Self Check before Merge

鈿狅笍 Please check all items below before review. 鈿狅笍

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Changelog is provided or not needed

@ElderJames
Copy link
Member

Thanks for contribution @zmayor .
We think the _dataSourceCache should be created instance before it is used.

@qinhuaihe
Copy link
Author

Is this ok?

public partial class Table<TItem> : ITable
{
    private readonly IDictionary<int, RowData<TItem>> _dataSourceCache = new Dictionary<int, RowData<TItem>>();

    private void FlushCache()
    {
        _dataSourceCache.Clear();
    }
    ...
}

@anddrzejb
Copy link
Member

@zmayor we already discussed the solution for this in #1138. I think your solution is ok, though @ElderJames suggested another one which may be more performant (a bit less allocation). I'd suggest to go with that one.

@ElderJames ElderJames merged commit 6825e1f into ant-design-blazor:master Feb 20, 2021
ElderJames pushed a commit that referenced this pull request Apr 23, 2022
* fix(module:table): set selectedRows exception

* fix(module:table): set selectedRows exception
ElderJames pushed a commit that referenced this pull request Apr 30, 2022
* fix(module:table): set selectedRows exception

* fix(module:table): set selectedRows exception
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.

Table selection throwing an exception occasionally
3 participants