Hello,
I am using Blazor Webassembly and working with DataGrid using RemoteSaveAdaptor. I want the sorting and filtering to be performed on the client side and only the CRUD operations to call the Web Api.
Unfortunately the Insert, Update and Remove Web APIs are not being called.
Could you please take a look? This is the code:
@page "/zonetaxi"
@inject HttpClient Http
<SfGrid TValue="Zona" AllowPaging="true" Toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel" })" Width="700">
<GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.Menu"></GridFilterSettings>
<GridPageSettings PageSize="15"></GridPageSettings>
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="EditMode.Dialog"></GridEditSettings>
<GridSelectionSettings PersistSelection="true" Type="SelectionType.Single"></GridSelectionSettings>
<SfDataManager Json="@Zone"
InsertUrl="http://185.104.180.42:8887/api/web/insert/zone"
UpdateUrl="http://185.104.180.42:8887/api/web/update/zone"
RemoveUrl="http://185.104.180.42:8887/api/web/delete/zone"
CrossDomain="true"
Adaptor="Syncfusion.Blazor.Adaptors.RemoteSaveAdaptor"
></SfDataManager>
<GridColumns>
<GridColumn Field="@nameof(Zona.ID)" HeaderText="Zona ID" Width="300" IsIdentity="true" IsPrimaryKey="true"></GridColumn>
<GridColumn Field="@nameof(Zona.Name)" HeaderText="Nume Zona" Width="250"></GridColumn>
</GridColumns>
<GridEvents TValue="Zona" OnActionFailure="Failure"></GridEvents>
</SfGrid>
@code {
public static List<Zona> Zone { get; set; }
protected override async Task OnInitializedAsync()
{
string responseText = await Http.GetStringAsync("http://185.104.180.42:8887/api/web/zone");
ResponseModel response = JsonConvert.DeserializeObject<ResponseModel>(responseText);
Zone = response.data;
base.OnInitialized();
}
private void Failure(FailureEventArgs e) {
Console.WriteLine(e.Error.Message);
Console.WriteLine(e.Error.StackTrace);
}
public class Zona
{
[JsonProperty("id")]
public int ID { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
}
public class ResponseModel
{
public string err;
public List<Zona> data;
public int count;
}
}