Problem deleting two rows and how to export to an excel the entire table or only a row

Hello!
I want to know if there is a problem in my code that generate a problem while deleting two rows. When i delete the first one there is no problem but when deleting the second one, the row is deleted but still appears in the data grid.
I will attach a rar with four images. The first is when i compile the program, second when i delete one row, third when i delete another row but still appears in the table and fourth the problem when i try again to delete the second row. Obviously the problem appears because i am trying to delete something that it is deleted, how can i refresh the data grid after someone delete a row?
Here the code:
@using Syncfusion.Blazor.Grids
@using Syncfusion.Blazor.Data
@using Syncfusion.Blazor.Calendars
@using Syncfusion.Blazor.DropDowns
@using Syncfusion.Blazor.Inputs
@using System.Configuration;
@using System.Data.SqlClient;
@using Entities
@using Business
@inject NavigationManager NavManager
"Delete"})">
AllowDeleting="true" Mode="@EditMode.Dialog">
@foreach (var operario in operarios)
{
}
@code {
public bool Enabled = true;
public bool Disabled = false;
List operarios = new List();
List categorias = new List();
List usuarios = new List();
List clientes = new List();
protected override async Task OnInitializedAsync()
{
operarios = B_Operario.OperarioList();
categorias = B_CatOpe.CategoriaList();
usuarios = B_Usuario.UsuarioList();
clientes = B_Cliente.ClienteList();
}
public void ActionBeginHandler(ActionEventArgs args)
{
if (args.RequestType == Syncfusion.Blazor.Grids.Action.BeginEdit)
{
// The Textbox component is disabled using its Enabled property
this.Enabled = false;
}
else
{
this.Enabled = true;
}
}
public class Moneda
{
public string ID { get; set; }
public string Text { get; set; }
}
List MonedaData = new List {
new Moneda() { ID= "Mon1", Text= "Peso Argentino"},
new Moneda() { ID= "Mon2", Text= "Dolar"},
new Moneda() { ID= "Mon3", Text= "Euro"}};
public class EstaActivo
{
public bool BActivo { get; set; }
public string Text { get; set; }
}
List ActivoData = new List {
new EstaActivo() { BActivo= true, Text= "SI"},
new EstaActivo() { BActivo= false, Text= "NO"}};
public void ActionBegin(ActionEventArgs args)
{
if (args.RequestType == Syncfusion.Blazor.Grids.Action.Save)
{ //from here you can call the AddMethod of you database.
B_Operario.CreateOrUpdateOperario(args.Data);
}
if (args.RequestType == Syncfusion.Blazor.Grids.Action.Delete)
{
B_Operario.RemoveOperario(args.Data);
}
}
}

And then here is were it is the function to delete each row
public static void RemoveOperario(OperarioEntity oOperario)
{
using (var db = new OperariosContext())
{
db.Operario.Remove(oOperario);
db.SaveChanges();
}
}

Apart from this i wanted to know how to make an excel file for all the data grid or only for one of the rows in the table.
Thanks for all, Best regards from Argentina.
Matias.

Attachment: Problem_deleting_2_rows_74db74e8.rar

3 Replies 1 reply marked as answer

VN Vignesh Natarajan Syncfusion Team August 19, 2020 10:50 AM UTC

Hi Matias, 
 
Greetings from Syncfusion support.  
 
Query: “When i delete the first one there is no problem but when deleting the second one, the row is deleted but still appears in the data grid. 
 
We have analyzed the reported issue by preparing a sample using DataGrid and bound data using EF core. Also we have handled the CRUD operation using the GridEvents (OnActionBegin). We are not able to reproduce the reported issue at our end while deleting records in Grid using built in CRUD actions . Kindly download the sample from below  
 
 
Note: to bind the EF data, kindly change the connectionstring in DataContext.cs file based on the Northwnd.mdf file from App_Data folder 
 
After referring the sample if you are still facing the issue, kindly get back to us with following details.  
 
  1. Grid code example.
  2. Syncfusion.Blazor Nuget package version details.
  3. If possible try to reproduce the reported issue in provided sample and revert back to us.
 
Above requested details will be helpful for us to validate the reported issue at our end and provide solution as early as possible.  
 
Query: “Apart from this i wanted to know how to make an excel file for all the data grid or only for one of the rows in the table. 
 
Grid data can be exported to Excel format using excel export feature of Grid. AllowExcelExport and ExcelExport() method of Grid is used to export all the Grid data to excel file. we have already documented your requirement in our UG documentation. Kindly refer the below documentation link for your reference    
 
https://blazor.syncfusion.com/documentation/datagrid/excel-exporting/#custom-data-source – using this, we can export the custom data with single record.  
 
Please get back to us if you have further queries.   
 
 
Regards, 
Vignesh Natarajan 


Marked as answer

MM Matias Mutz August 28, 2020 02:43 AM UTC

Thank you very much. It went really well. I have another problem for which i made a new thread. Greetings from Argentina!


VN Vignesh Natarajan Syncfusion Team August 28, 2020 05:20 AM UTC

Hi Matias,  

Thanks for the update.  

We are glad to hear that you have achieved your requirement using our solution. 

Please get back to us if you have further queries.  

Regards, 
Vignesh Natarajan 


Loader.
Up arrow icon