dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.37k stars 9.99k forks source link

quickgrid blazorwebassmelby with .net8.0 #53041

Closed Techrese closed 9 months ago

Techrese commented 9 months ago

Is there an existing issue for this?

Describe the bug

I have several issues/possible bugs in blazor quickgrids using .net8.0 to start of i'm using the visual studio 2022 17.8.3 I created the default template blazor webapp and have selected webassembly.

Following the docs: https://aspnet.github.io/quickgridsamples/sorting/ and example https://www.youtube.com/watch?v=sVrWK5GAPgU&t=648s

The first issue that I have is the columns don't sort when using 'sortable="true" The second issue that I have is wehn using a templatecolumn to put a button. The button is there however it doesn't execute the method behind it when using onclick event.

for this project you can view my code https://github.com/Techrese/.NET-Samples/commit/85926fba8fcd89c074b9039b0c13ccbe7b24db59

For a last issue I seem to be having problems with two way binding when using editform. I had filed a question on stackoverflow: https://stackoverflow.com/questions/77722131/blazor-net8-0-editform-model-not-binding

i also have a simple poc at https://github.com/Techrese/.NET-Samples/commit/053bc0ac9748762dfa349836e7b6fba2a7dc105e

Expected Behavior

for quickgrids expected behaviour would be sortable columns And execute the action behind the button onclick event

for editform the expected result would be binding to the model when submitting.

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

8.0.100

Anything else?

No response

Techrese commented 9 months ago

Upon further investigation, since the default counter page has a button and some information on the microsoft docs.

I have discovered that the button never executes when using a lambda expression, but when executing normally using eventcallback, the action behind the button is called when opening the page, but never when clicked on it.

<td><button type="button" class="@(Indicator(item))" @onclick="@(ToggleRecord(item))">Test</button></td>

Both tested in UI and UI.Client assmelby, and both tested in brave browser and microsoft edge.

Investigating even further I also created a blazor server app (net7.0 because 8.0 wasn't available, I don't know why)

when using the standard lambda expression it is working fine.

<button class="btn btn-primary" @onclick="@(() => SetCount(10))">Click me</button>

javiercn commented 9 months ago

@Techrese thanks for contacting us.

Event handlers are only valid in interactive render modes. Seems that the components on your app are running statically, so any behavior attached to events will not run.

javiercn commented 9 months ago

You need to use @rendermode either on the call site here (for example) or on the component itself.

Techrese commented 9 months ago

You need to use @rendermode either on the call site here (for example) or on the component itself.

Ah yes thanks you, I had found somethin gonline with 'streamrendering' on the component itself but didn't work, Interactivewebassembly didn't work either here, but interactiveservermode worked for me thanks.

ghost commented 9 months ago

This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes.

See our Issue Management Policies for more information.