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
close icon

EjsGrid behavior change with fully dynamyc dataset

Using 17.3 before, I can construct a grid like this :

<EjsGrid ID=@("odqGrid" + Parameters.Identifier) @ref=@grid TValue="object" AllowPaging="true" AllowResizing=true Width="100%" Height="100%">
    <GridEvents TValue="object" RowSelected="OnRowSelectedHandler" OnRecordDoubleClick="OnDoubleClickHandler"></GridEvents>
    <GridPageSettings PageSize="25" />
    <EjsDataManager Url=@(RestClient.RootUrl + "odata/configurations/00000000-0000-0000-0000-000000000000/data/") Adaptor="Adaptors.WebApiAdaptor"></EjsDataManager>
    <GridColumns>
        @foreach (var field in this.Parameters.CurrentConfiguration.DisplayFields)
        {
            <GridColumn HeaderText=@field.DisplayName
                        Field=@field.DataName
                        Format=@(field.Format ?? "")
                        IsPrimaryKey=@field.IsPrimaryKey
                        Width=@field.Width
                        Visible=@field.Visible />
        }
    </GridColumns>
</EjsGrid>

I used the TValue to object and the grid was kind enough to take a look to the field name of the datasource to make the databind. Witth the 17.4.x version supports this scenario ?

Regards.

5 Replies

VN Vignesh Natarajan Syncfusion Team January 13, 2020 03:53 PM UTC

Hi Brice,  
 
Thanks for contacting Syncfusion support.  
 
Query:” I used the TValue to object and the grid was kind enough to take a look to the field name of the datasource to make the databind. With the 17.4.x version supports this scenario ? 
 
After our 2019 Volume 4 release (17.4.0.39), TValue must be Generic Type. Tvalue must be type of business object instead of dynamic/object when using remote data. In our source, we use HttpClient to sent request to server to fetch data from it. So we have deserialized the data based on the TValue object. So kindly use business object type TValue to resolve the query.  
 
Or If you still want to use Dynamic object with remote data, then we suggest you to external methods like getJsonAsync of HttpClient to fetch data from server and bind to Grid using ExpandoObject. Refer the below code example.  
 
<EjsGrid @ref=@grid TValue="ExpandoObject" DataSource="@Orders" AllowPaging="true" AllowResizing=true Width="100%" Height="100%"> 
     . . . . . . . . . . .  
</EjsGrid> 
 
@code{ 
    EjsGrid<ExpandoObject> grid { get; set; } 
    public List<ExpandoObject> Orders { get; set; } 
    protected override async Task OnInitializedAsync() 
    { 
        Orders = await OrderData.GetStudentsAsync(); 
    } 
}. . . . . . . . 
public async Task<List<ExpandoObject>> GetStudentsAsync() 
        { 
            HttpClient http = new HttpClient();             
            var json = await http.GetStringAsync("https://localhost:44349/api/Default"); 
            return JsonConvert.DeserializeObject<List<ExpandoObject>>(json); 
        } 
              
Please get back to us if you have any other queries.  
 
Regards, 
Vignesh Natarajan.  



BF Brice FROMENTIN January 17, 2020 04:26 PM UTC

Hello,

Sorry with your explanation, it don't work.

If I use your method, I have the right number of lines but they are empty, I also try a custom Adaptor so it looks better integration but nothings work at all.

Do you have a sample with a custom adaptor and ExpandoObject that works on the grid ?


RS Renjith Singh Rajendran Syncfusion Team January 21, 2020 12:47 PM UTC

Hi Brice, 

Thanks for contacting Syncfusion support. 

Based on the previously suggested solution, we have prepared a sample to bind ExpandoObject to Grid. Please download the sample from the link below, 
 
If you are still facing difficulties, kindly share with us the sample which you have tried from your side, for further analysis. 

Please get back to us if you need further assistance. 

Regards, 
Renjith Singh Rajendran. 



BF Brice FROMENTIN January 25, 2020 04:59 PM UTC

Thanks it now works.


RS Renjith Singh Rajendran Syncfusion Team January 27, 2020 05:15 AM UTC

Hi Brice, 

Thanks for your update. 

We are happy to hear that your problem has been resolved. 

Please get bac to us if you need further assistance. 

Regards, 
Renjith R. 


Loader.
Live Chat Icon For mobile
Up arrow icon