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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(DataTableDynamicContext): Items not updated after its DataTable got changed #5384

Closed
1 task done
jvk-digres opened this issue Feb 17, 2025 · 4 comments · Fixed by #5389
Closed
1 task done

bug(DataTableDynamicContext): Items not updated after its DataTable got changed #5384

jvk-digres opened this issue Feb 17, 2025 · 4 comments · Fixed by #5389
Assignees
Labels
bug Something isn't working
Milestone

Comments

@jvk-digres
Copy link
Contributor

jvk-digres commented Feb 17, 2025

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When I edit DataTableDynamicContext's DataTable GetItems() returns old items.

Expected Behavior

DataTableDynamicContext.GetItems() should always return rows from DataTableDynamicContext.DataTable.

Interactive render mode

Interactive Server (Interactive server-side rendering (interactive SSR) using Blazor Server)

Steps To Reproduce

Repo: https://github.com/jvk-digres/DataTableDynamicContext_ItemsNotUpdated

Exceptions (if any)

No response

.NET Version

NET9.0

Anything else?

There's also a bug (i think?) when adding new objects with DataTableDynamicContext.AddAsync. Items are not updated when OnAddAsync is set.

@jvk-digres jvk-digres added the bug Something isn't working label Feb 17, 2025
Copy link

bb-auto bot commented Feb 17, 2025

@jvk-digres Thank you for filing this issue. In order for us to investigate this issue, please provide a minimalistic repro project that illustrates the problem.

@bb-auto bb-auto bot added this to the v9.3.0 milestone Feb 17, 2025
@ArgoZhang
Copy link
Collaborator

ArgoZhang commented Feb 18, 2025

@jvk-digres hi. I submitted a PR for this issue in the repo. jvk-digres/DataTableDynamicContext_ItemsNotUpdated#1

For performance reasons, the method GetItems uses caching technology internally. If you need, we can design a property to control whether to use caching. However, I recommend reconstructing DataTableDynamicContext whenever you update the data source.

AddAsync

add sample code please take a look jvk-digres/DataTableDynamicContext_ItemsNotUpdated#2

@ArgoZhang
Copy link
Collaborator

@jvk-digres

add UseCache parameter default value is true

now. you can use this parameter to refactor your code

DataTableDynamicContext = new DataTableDynamicContext(dataTable, (context, column) =>
{
    column.Visible = true;
})
{
    UseCache = false
};

@jvk-digres
Copy link
Contributor Author

I can confirm this works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants