Use SfDataManager to populate the grid.
<SfGrid TValue="OrderItem">
<SfDataManager Url="https://www.mydomain.com/api/orderitemwithcount/1002" Adaptor="Adaptors.WebApiAdaptor"></SfDataManager>
<GridColumns>
<GridColumn Field=@nameof(OrderItem.OrderId) HeaderText="Order Id"></GridColumn>
<GridColumn Field=@nameof(OrderItem.ProductCode) HeaderText="Code"></GridColumn>
<GridColumn Field=@nameof(OrderItem.ProductName) HeaderText="Name"></GridColumn>
<GridColumn Field=@nameof(OrderItem.ProductSku) HeaderText="Sku"></GridColumn>
</GridColumns>
</SfGrid>
Note: The result xml/json must contain Items and Count properties.
public class OrderItemWithCount
{
public List<DCOrderItem> Items { get; set; }
public int Count
{
get => Items.Count;
}
}
public OrderItemWithCount Get(int id)
{
WSOrderClient wsOrder = new WSOrderClient("BasicHttpsBinding_IWSOrder");
OrderItemWithCount result = new OrderItemWithCount();
result.Items = wsOrder.GetOrderItemList(id);
wsOrder.Close();
return result;
}
Comments