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

EjsDataManager does not display records

I set up [ApiController] [Route("api")] and tested that it works by typing http://..../api in browser.

I also set breakpoint on return new { Items = ..., Count = ...} statement

          <EjsGrid>
<EjsDataManager Url="api" Adaptor="Adaptors.WebApiAdaptor"></EjsDataManager>

hits breakpoint, but nevertheless no records are displayed in the grid.


I noticed that there is Adaptors.BlazorAdaptor but not found any documentation of using it. Ideally it would be better to have an ability to call await GetData(skip, take) method on blazor control directly instead of  creating api.



8 Replies

VN Vignesh Natarajan Syncfusion Team September 16, 2019 07:16 AM UTC

Hi Andrey,  

Greetings from Syncfusion support.  

Query1: “hits breakpoint, but nevertheless no records are displayed in the grid. 
 
We suspect that you are facing Camel Case issue in Asp.Net Core. Normally, ASP.NET Core 1.0+ framework has camel casing issues while serializing the JSON Object. If you are facing the same camel casing issue while running the sample then please use the below codes in Startup.cs file to overcome that casing issue in Application level.  
 
In the below code, we have called the ContractResolver options under the Startup.cs file to avoid camel casing conversion during the serialization process. The is related to ASP.NET Core specifics and we suggest refer to the following article which describes how to overcome a similar issues. 
 
 
Please use the code below, 

[Startup.cs] 
 
        public void ConfigureServices(IServiceCollection services) 
        { 
 
            services.AddMvc().AddNewtonsoftJson(options => { 
                options.SerializerSettings.ContractResolver = new DefaultContractResolver(); 
            }); 
       } 

 
Note: WebAPI controller must return the values in form of Items and Count (refer below screenshot). Kindly ensure this in your sample.  

 

For your convenience we have prepared a sample which can be downloaded from below  

Refer our UG documentation for your reference 


Query2: “I noticed that there is Adaptors.BlazorAdaptor but not found any documentation of using it 
 
By default, Grid will consider the Adaptor Type as BlazorAdpator if we bind the dataSource in form of List of objects or IEnumerable. So it is not necessary to define Blazor adaptor separately in EjsDataManager. Refer our UG documentation for your reference. 
 

Please get back to us if you have further queries.   

Query3: “Ideally it would be better to have an ability to call await GetData(skip, take) method on blazor control directly instead of  creating api 

You can use GetJsonAsync() method of http to retrieve the entire data from WebAPI controller to bind it to Grid in the form of list of objects. But this requirement can be achieve while using Client Side Blazor or Hosted Blazor Application. So kindly confirm your Blazor Application type. Based on your confirmation, we will provide the solution / possible way to retrieve data from API controller      

Regards, 
Vignesh Natarajan.  



MA Mr Andrey Voronov September 16, 2019 10:47 AM UTC

 Adding  services.AddMvc().AddNewtonsoftJson  fixed records displaying issue. But templated colums are not displaying (System.ArgumentException: Property set method not found) when I am using WebApiAdaptor




VN Vignesh Natarajan Syncfusion Team September 17, 2019 11:58 AM UTC

Hi Manuel, 
  
Thanks for the update.  
  
Query: “But templated columns are not displaying (System.ArgumentException: Property set method not found) when I am using WebApiAdaptor” 
  
The reported issue is occurred when using the Model class with read-only properties (i.e) without set property in class definition. While using WebAPI Adaptor data will be returned in the form of string from the server. So they will be deserialized based on the model class provided in ModelType and assign it to context. Since you have defined some properties as read-only (i.e) without set property the reported issue is occurred. You can resolve the reported issue in either way.  
  
  1. Define the read-only properties by using readonly attribute instead of ignoring the set property. Refer the below code example
  
public class Orders 
    { 
        public long OrderID { get; set; } 
        public readonly string CustomerID = "Vinet"; 
        public int EmployeeID { get; set; } 
        .       .         .           .  
    } 
     
  1. Or you can also create another model Class with similar properties (ie. with getter and setter properties) and define that class as ModelType value. Refer the below code example
  
<EjsGrid TValue="OrdersDetails" ModelType="@Model" AllowPaging="true"> 
    <EjsDataManager Url="api/Default" Adaptor="Adaptors.WebApiAdaptor"></EjsDataManager> 
…………………………………. 
</EjsGrid> 
  
@code{ 
    public List<OrdersDetails> Order = new List<OrdersDetails>(); 
    public OrdersDetails Model = new OrdersDetails(); 
    public class ViewModel 
    { 
        public long OrderID { get; set; } 
        public string CustomerID { get; set; } 
        .            .           .          .           .           .  
    } 
} 
  
  
Please get back to us if you have further queries.   
   
Regards, 
Vignesh Natarajan. 



MA Mr Andrey Voronov September 18, 2019 02:55 PM UTC

My POCO model has no read-only fields, but has TimeSpan { get; set;} property. 

WebApiAdaptor does not displays templated fields if POCO model has TimeSpan properties..





VN Vignesh Natarajan Syncfusion Team September 19, 2019 09:06 AM UTC

Hi Andrey,  

Query: “WebApiAdaptor does not displays templated fields if POCO model has TimeSpan properties.. 

We are able to reproduce the reported issue at our end too while preparing a sample as per your suggestion. We have considered the reported issue as a bug and logged defect report “Template column is not rendered properly while using Model class with TimeSpan property and WebAPI adaptor” for the same. Fix for the issue will be included in our upcoming Nuget release which is expected to be roll out in the first week of October 2019. 

You can track the status of the issue and contact us through the below feedback portal 


Till then we appreciate your patience. 

Regards,
Vignesh Natarajan.



MA Mr Andrey Voronov October 4, 2019 12:17 PM UTC


EjsDataAdapter' TimeSpan  issue still not has been fixed in the latest 17.3.11 release.

I am getting:

Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing number: :. Path '', line 1, position 2.
   at Newtonsoft.Json.JsonTextReader.ReadNumberCharIntoBuffer(Char currentChar, Int32 charPos)
   at Newtonsoft.Json.JsonTextReader.ReadNumberIntoBuffer()
   at Newtonsoft.Json.JsonTextReader.ParseNumber(ReadType readType)
   at Newtonsoft.Json.JsonTextReader.ParseValue()
   at Newtonsoft.Json.JsonReader.ReadAndMoveToContent()
   at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type)
   at Syncfusion.EJ2.Blazor.BaseComponent.ChangeType(Object value, Type conversionType)
   at Syncfusion.EJ2.Blazor.BaseComponent.GetObject(Dictionary`2 Data, Type ModelType)
   at Syncfusion.EJ2.Blazor.Grids.GridColumn.BuildRenderTree(RenderTreeBuilder __builder)
   at Microsoft.AspNetCore.Components.ComponentBase.<.ctor>b__6_0(RenderTreeBuilder builder)
   at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.RenderInExistingBatch(RenderQueueEntry renderQueueEntry)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue()


VN Vignesh Natarajan Syncfusion Team October 7, 2019 10:28 AM UTC

Hi Andrey,  

We regret for the inconvenience caused.  

Due to some unforeseen circumstances, we will not be able to include the fix for this bug Template column is not rendered properly while using Model class with TimeSpan property and WebAPI adaptor in our latest Nuget release. But we will fix this bug and this will be included in our subsequent Bi-Weekly Nuget release which is expected to be rolled out on or before 16th October 2019.  

Until then we appreciate your patience. 

Regards, 
Vignesh Natarajan.


VN Vignesh Natarajan Syncfusion Team October 11, 2019 07:25 AM UTC

Hi Andrey,  
 
We are glad to inform that our latest Nuget package (17.3.0.17-beta) has been successfully rolled out. In this release we have included the fix for the issue “Template column is not rendered properly while using Model class with TimeSpan property and WebAPI adaptor”. Please find the latest Nuget package and release notes regarding the changes in Grid from below   
 
 
 
Also ensure that you have referred the latest version script and css as below  
 
<link rel='nofollow' href="https://cdn.syncfusion.com/ej2/17.3.17/fabric.css" rel="stylesheet" /> 
    <script src="https://cdn.syncfusion.com/ej2/17.3.17/dist/ej2.min.js"></script>  
    <script src="https://cdn.syncfusion.com/ej2/17.3.17/dist/ejs.interop.min.js"></script> 
 
 
Please get back to us if you have further queries. 
 
Regards, 
Vignesh Natarajan. 
 


Loader.
Up arrow icon