How to enable editing in SfGrid

Hi,
I have a Blazor Server app which displays user data.
The data is pulled from SQL Server (using Dapper) and displayed in a Bootstrap table.
Adding data is handled on a separate page (e.g.: "/users/add").

I saw a video where the SfGrid can have inline Add/Update/Delete functions.
I am able to load data into a SfGrid, but cannot enable the CRUD functions.
How do I do this?

For example:
If I click a Add button, the "AddUsers" function should run with the data the user entered in the SfGrid.
And so on for the rest of the functions...

Any help is appreciated.

Thanks.

3 Replies 1 reply marked as answer

JP Jeevakanth Palaniappan Syncfusion Team October 19, 2020 09:52 AM UTC

Hi Preveen, 

Greetings from Syncfusion support. 

Query: How to enable editing in SfGrid 

We have validated your query and you can achieve your requirement by enabling AllowAdding, AllowEditing, AllowDeleting as true in the GridEditSettings. Please find the below code snippet and the documentation for your reference. 

<SfGrid DataSource="@GridData" Toolbar="@(new string[] {"Add", "Edit" ,"Delete","Update","Cancel" })"> 
    <GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true"> 
.. 
.. 
</SfGrid> 


Regards, 
Jeevakanth SP. 



PR Preveen October 19, 2020 04:43 PM UTC

Thanks for the reply.

I'm using Dapper, which the documentation doesn't cover.

I don't want to use DataAdapters etc...


JP Jeevakanth Palaniappan Syncfusion Team October 20, 2020 01:12 PM UTC

Hi Preveen, 

We have prepared a sample based on your requirement. Please download it from the below link. 


Note: please change the connectionstring in appsettings.json file based on the MDF file placed in App_Data folder.  
  
Kindly get back to us if you have further queries.   

Regards, 
Jeevakanth SP. 


Marked as answer
Loader.
Up arrow icon