BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
Hi
I’m using WebApiAdaptor
in the grid, but the result is an empty grid even if the API is returning values. Adding items works fine.
If I load
the grid with OnInitializedAsync() and using Http.GetJsonAsync()
everything works.
See
attached sample.
[HttpGet]
public object Get()
{
var orders = new List<Order>();
. . . . . . . . . . .
return new { Items = orders,Count = orders.Count() };
} |
...
<EjsGrid Height="315" TValue="OrdersDetails" Toolbar="@(new List<string>() { "Add", "Delete", "Update", "Cancel" })">
<EjsDataManager AdaptorInstance="@typeof(CustomAdaptor)" Adaptor="Adaptors.CustomAdaptor"></EjsDataManager>
<GridEditSettings AllowEditing="true" AllowDeleting="true" AllowAdding="true" Mode="@EditMode.Normal"></GridEditSettings>
<GridColumns>
<GridColumn Field=@nameof(OrdersDetails.OrderID) HeaderText="Order ID" IsPrimaryKey="true" TextAlign="TextAlign.Right" Width="120"></GridColumn>
...
</GridColumns>
</EjsGrid>
@code{
public static List<OrdersDetails> forecasts;
protected override async Task OnInitializedAsync()
{
forecasts = await Http.GetJsonAsync<List<OrdersDetails>>("api/Default");
}
public class CustomAdaptor : DataAdaptor
{
// Performs data Read operation
public override object Read(DataManagerRequest dm, string key = null)
{
...
return dm.RequiresCounts ? new DataResult() { Result = DataSource, Count = count } : (object)DataSource;
}
// Performs Insert operation
public override object Insert(DataManager dm, object value, string key)
{
...
}
// Performs Remove operation
public override object Remove(DataManager dm, object value, string keyField, string key)
{
...
}
// Performs Update operation
public override object Update(DataManager dm, object value, string keyField, string key)
{
...
}
}} |