Remote data datagrid don't work
Hi, I followed this guide, the API from the SWAGGER mode of the API server works perfectly, ditto using the link directly, but the client does not receive anything, here is the code
<body> <SfGrid @ref="sfGrid" TValue="ListaProgrammazione" AllowPaging="true" AllowFiltering="true" AllowSorting="true" Toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel", "Search" })"> <SfDataManager Url="https://localhost:7271/api/GetProgrammazioneVideo" InsertUrl="https://localhost:7271/api/InsertProgrammazioneVideo" UpdateUrl="https://localhost:7271/api/UpdateProgrammazioneVideo" RemoveUrl="https://localhost:7271/api/DeleteProgrammazioneVideo" Adaptor="Adaptors.UrlAdaptor"></SfDataManager> <GridEditSettings AllowEditing="true" AllowDeleting="true" AllowAdding="true" Mode="EditMode.Normal"></GridEditSettings> <GridColumns> <GridColumn Field=@nameof(ListaProgrammazione.ID) HeaderText="ID" IsIdentity="true" ValidationRules="@(new ValidationRules{ Required= true })" IsPrimaryKey="true" TextAlign="TextAlign.Right" Width="120"></GridColumn> <GridColumn Field=@nameof(ListaProgrammazione.dt_pubblicazione) HeaderText="Pubblicato Il" TextAlign="TextAlign.Right" Width="150"></GridColumn> <GridColumn Field=@nameof(ListaProgrammazione.dt_registrato) HeaderText="Registrato Il" TextAlign="TextAlign.Right" Width="150"></GridColumn> <GridColumn Field=@nameof(ListaProgrammazione.dt_editato) HeaderText="Editato Il" TextAlign="TextAlign.Right" Format="C2" Width="150"></GridColumn> <GridColumn Field=@nameof(ListaProgrammazione.tipologia_video) HeaderText="Tipologia Video" Width="150"></GridColumn> <GridColumn Field=@nameof(ListaProgrammazione.durata_video) HeaderText="Durata Video" Width="150"></GridColumn> <GridColumn Field=@nameof(ListaProgrammazione.nome_video) HeaderText="Nome Video" Width="150"></GridColumn> <GridColumn Field=@nameof(ListaProgrammazione.videogioco) HeaderText="Videogioco" Width="150"></GridColumn> <GridColumn Field=@nameof(ListaProgrammazione.youtube) HeaderText="Youtube" Width="150"></GridColumn> <GridColumn Field=@nameof(ListaProgrammazione.twitch) HeaderText="Twitch" Width="150"></GridColumn> </GridColumns> </SfGrid> </body> @code { SfGrid<ListaProgrammazione> sfGrid { get; set; } public static List<ListaProgrammazione>? listaProgrammaziones { get; set; } public class ListaProgrammazione { public int? ID { get; set; } public DateTime? dt_pubblicazione { get; set; } public DateTime? dt_registrato { get; set; } public DateTime? dt_editato { get; set; } public string? tipologia_video { get; set; } public string? durata_video { get; set; } public string? nome_video { get; set; } public string? videogioco { get; set; } public int? youtube { get; set; } public int? twitch { get; set; } } |
Hi Daniele,
Based on the reported problem, we suspect that the issue may be related to the
CORS policy configuration in your service project's Program.cs file. Please
verify if the CORS policy is correctly configured. Kindly refer to the code
snippet and sample provided below for your reference.
|
{ options.AddPolicy("NewPolicy", builder => builder.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader()); }); var app = builder.Build();
if (app.Environment.IsDevelopment()) { app.UseSwagger(); } app.UseHttpsRedirection(); app.UseRouting(); app.UseCors("NewPolicy"); |
Note : After connecting the database, we need to copy the path of
the database and change the connection string with the copied path in
GridController.cs file based on the NORTHWND.MDF file
If the issue persists, please share a reproducible sample with duplicate data,
or try to reproduce the reported issue using the previously attached sample.
Additionally, please clarify whether you are facing the issue with data binding
or while performing CRUD operations on the grid. Kindly share these details,
and we will provide a solution as soon as possible.
Regards,
Prathap Senthil
Attachment: BindingSqlData_7dd92fac.zip