-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
How to render a matrix correctly in Blazor? #49945
Comments
Have you tried to use a for instead of a while ? Like: I think the main problem is you attempt to increment a value in a while, but basicaly, a while not used in a thread block the mainthread. |
@bub-bl Not sure I understand what you mean. I am incrementing |
When you pass a loop variable to a child component in a loop, you need to capture that variable in a new parameter:
You should also use a @key attribute, especially if you're going to insert/delete rows. |
@Markz878 I got it. Thanks! |
Thanks for assisting with this, @Markz878! @sam-wheat I assume that resolved your problem, didn't it? |
We have this guidance in a few relevant spots where devs ran into it 😈 in the past, for example ...
I'm making a note on one of my tracking issues to call it out in a component parameter example, too. |
@mkArtakMSFT Yes many thanks to all. |
Is there an existing issue for this?
Describe the bug
I need to render some objects in a matrix - basically a table with a variable number of columns.
In the case of the example below I need four columns.
The problem code is below. As indicated in the comment
rowIndex
variable is stuck at 4. I apparently have somekind of closure problem (?) but IDK what it is. What am I doing wrong here?
Runnable project is attached showing expected output.
This is my first Blazor project for a large client. I hope to impress them favorably with Blazor. Thank you for your assistance with this.
Expected Behavior
Steps To Reproduce
See
Index.razor
in attached projectExceptions (if any)
No response
.NET Version
7.0.306
Anything else?
MatrixTest.zip
The text was updated successfully, but these errors were encountered: