We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

CustomAdaptor does not work with Grid - TValue="ExpandoObject"

Hi,

I try to make a custom adaptor with a ExpandoObeject grid but with no success, please note that it works with Adaptor="Adaptors.WebApiAdaptor"

here is the code :

Grid:
                    <EjsGrid TValue="ExpandoObject" AllowResizing="true" AllowPaging="true" Width="100%" Height="100%">
                        <GridPageSettings PageSize="50" />
                        <EjsDataManager Adaptor="Adaptors.CustomAdaptor">
                            <OdqDataAdaptor Url="odata/configurations/00000000-0000-0000-0000-000000000000/data/"></OdqDataAdaptor>
                        </EjsDataManager>
                        <GridColumns>
                            <GridColumn Field="Id" HeaderText="Order ID" IsPrimaryKey=true TextAlign="TextAlign.Right" Width="120"></GridColumn>
                            <GridColumn Field="Description" HeaderText="Description" Width="auto"></GridColumn>
                            <GridColumn Field="Date" HeaderText="Order Date" Format="yMd" Type="ColumnType.Date" TextAlign="TextAlign.Right" Width="130"></GridColumn>
                            <GridColumn Field="Freight" HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right" Width="120"></GridColumn>
                        </GridColumns>
                    </EjsGrid>


Custom Adaptor :

@using Syncfusion.EJ2.Blazor;
@using Syncfusion.EJ2.Blazor.Data;
@using Kairos.Models.Odq;

@inherits DataAdaptor<object>
@inject HttpClient  httpClient

<CascadingValue Value="@this">
    @ChildContent
</CascadingValue>

@code
{
    [Parameter]
    public RenderFragment ChildContent { get; set; }

    [Parameter]
    public string Url { get; set; }

    public override async Task<object> ReadAsync(DataManagerRequest dataManagerRequest, string key = null)
    {
        var restClient = new RestClient(httpClient);
        var result = await restClient.GetAsync<OdqFromConfigurationModel>(this.Url);

        return new DataResult<ExpandoObject>() { Count = result.Count, Result = result.Items };
    }
}

Thanks.


3 Replies

VN Vignesh Natarajan Syncfusion Team January 27, 2020 12:12 PM UTC

 
Thanks for contacting Syncfusion support.  
 
Query: “I try to make a custom adaptor with a ExpandoObeject grid but with no success, please note that it works with Adaptor="Adaptors.WebApiAdaptor" 
 
We are able to reproduce the reported behavior at our end while preparing a sample using your code example. Kindly modify your code example as below to resolve your issue.  
 
public override async Task<object> ReadAsync(DataManagerRequest dataManagerRequest, string key = null) 
    { 
        result = await Service.GetOrdersAsync(); 
     return dm.RequiresCounts ? new DataResult() { Result = result, Count = count } : (object)DataSource; 
       } 
 
For your convenience we have prepared a sample which can be downloaded from below    
 
 
Please get back to us if you have further queries.   
 
Regards,
Vignesh Natarajan.
 
 



BF Brice FROMENTIN January 27, 2020 05:24 PM UTC

Thanks, it works perfectly.


VN Vignesh Natarajan Syncfusion Team January 28, 2020 03:41 AM UTC

Hi Brice,  
 
Thanks for the update.  
 
We are glad to hear that you are able to resolve your query using our solution.  
 
Kindly get back to us if you have further queries.  
 
Regards, 
Vignesh Natarajan.  


Loader.
Live Chat Icon For mobile
Up arrow icon