Code Generator: Grid: Update does not work

After successfully using the Blazor Code Generator to configure a grid control, it compiles and runs. However, the Update and delete functions do not work.

See attached a working application with the Northwind database.  

You will need to adjust the connection string in appsettings.json of course.

Cheers,

Miles

Attachment: SyncfusionBlazorApp2_c9990e45.rar

3 Replies 1 reply marked as answer

VN Vignesh Natarajan Syncfusion Team June 4, 2021 05:29 AM UTC

Hi Miles,  
 
Thanks for contacting Syncfusion support.  
 
Query: “ Blazor Code Generator to configure a grid control, it compiles and runs. However, the Update and delete functions do not work. 
 
From your query we understand that you are facing trouble while updating/deleting a record in Grid. In the attached project we could not find the Northwnd database, hence we are not able to analyze the reported with provided sample. So kindly share the Northwnd database file to validate the reported issue at our end.  
 
Regards, 
Vignesh Natarajan 



MG Miles Gibson June 4, 2021 01:08 PM UTC

The Northwind Database is a standard Microsoft database used world-wide for example applications.  Below is a link from Microsoft where you can can download the .sql code to create the database (and data).

https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/sql/linq/downloading-sample-databases

Cheers,

Miles


VN Vignesh Natarajan Syncfusion Team June 7, 2021 04:18 AM UTC

Hi Miles,  
 
Thanks for the update.  
 
We are able to load data in Grid component in your sample with the provided sql script. We are able to reproduce the reported issue in the provided sample. From your code example, we found that you have not defined Primary key column. Based on the primary key column value only, CRUD operation in Grid will take place.  
 
We request you define the primary key column using IsPrimaryKey property of GridColumn whose value is unique. We have used CategoryId column value as PrimaryKey column. Refer the below code example.  
 
<SfGrid @ref="@DataGrid" TValue="Category" ID="Grid1" AllowPaging="true" AllowFiltering="true" AllowReordering="true" AllowResizing="true" AllowGrouping="true" AllowExcelExport="true" AllowPdfExport="true" AllowSelection="true" AllowSorting="true" Toolbar="@(new List<string>() { "Add""Edit""Delete""Cancel""Update","ExcelExport","PdfExport""CsvExport","Search"})"> 
            <GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="Syncfusion.Blazor.Grids.EditMode.Normal"></GridEditSettings> 
            <GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.FilterBar"></GridFilterSettings> 
            <GridPageSettings PageSizes="true"></GridPageSettings> 
            <SfDataManager AdaptorInstance="@typeof(GridCustomAdaptor)" Adaptor="Adaptors.CustomAdaptor"></SfDataManager> 
            <GridSelectionSettings Type="Syncfusion.Blazor.Grids.SelectionType.Multiple"></GridSelectionSettings> 
            <GridEvents OnToolbarClick="@GridToolbarClick" TValue="Category"></GridEvents> 
            <GridColumns> 
                <GridColumn Type="ColumnType.CheckBox" Width="50"></GridColumn> 
                <GridColumn Field=@nameof(Category.CategoryId) HeaderText="ID" IsPrimaryKey="true" Width="150"></GridColumn> 
                <GridColumn Field=@nameof(Category.CategoryName) HeaderText="CategoryName" Width="150"></GridColumn> 
                <GridColumn Field=@nameof(Category.Description) HeaderText="Description" Width="150"></GridColumn> 
                <GridColumn Field=@nameof(Category.Picture) HeaderText="Picture" Width="150"></GridColumn> 
                <GridColumn Field=@nameof(Category.Products) HeaderText="Products" Width="150"></GridColumn> 
            </GridColumns> 
        </SfGrid> 
 
  
Refer our UG documentation for your reference 
 
 
Please get back to us if you have further queries.  
 
Regards, 
Vignesh Natarajan 


Marked as answer
Loader.
Up arrow icon