Hi, I am using a datagrid, a .net 8 blazor web app auto, to load data from my task table. the table contains a series of booleans. I am trying to put switches (or checkboxes..it doesn't matter) so that I can change the value from true to false and vice versa. What I am trying to do is update the row as soon as the value in any of the switched/checkboxes change. I have tried several ways to do this, but can't get the row to update. The DataGrid Column looks like this
Just looking for the right direction to go in on this...I have tried similar code to this. I also tried re loading the orginal table, filter for the TaskID and try to update that, but can't get anything to work...please help point me in the right direction....
Yes, and that works fine if I am using an inline edit with a save button, but I am trying to accomplish something different. When the switch triggers the change event, I want it to update the row then, not update the control then click a save button. I was able to accomplish this in Server, but in this new .net 8 model, it doesn't work the same way.
Server side EF entities will react immediately after change and you will see the updated values in the DataGrid. Client side you will need to call Reload() for the entire grid.
I'm definitely missing something then. Created a basic test Blazor 8 web app auto. Create a 3 column table in ms sql with a description and one boolean non nullable. Created a Crud form in Radzen. When to the Main page with the datagrid. Changed the boolean column to a Switch and created the following code.
I created a table with just 3 columns, a primary key, a name and a bool. Here is the entire code behind.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.JSInterop;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using Radzen;
using Radzen.Blazor;
namespace SwitchTest.Client.Pages
{
public partial class Accounts
{
[Inject]
protected IJSRuntime JSRuntime { get; set; }
I am not sure what you are trying to achieve to be honest. The UpdateRow method of RadzenDataGrid will not update your database for sure. It will only trigger the RowUpdate event. You need to handle it and update the database there. You can use the inline edit page template as a start.
After a few experiments, I have found the issue. In my task table, there is a column for an image for each task. The task table is linked to a Task Type table via the TaskTypeID. It seems that when I insert an image into the Task table,(not sure if its the link), I am no longer able to save any updates to the Task Table. I even when back and created nothing more than a standard crud page for the task table and even that would not save. If I removed the image and replaced it with some random text...it saved fine....Just an FYI, that is what I have found.
Having me look at the inline edit examples helped me tremendously.
So now I an only storing the file location for use instead of the whole image file.
Now just trying to wrap my head around how to get the location using either fileinput or updload. I have manually entered the locations for now, since there are very few of them and no reason to really update them...