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

Error TypeError: this.model.currentViewData is undefined

Hi, i'm using Syncfusion Grid Control with a WebApi.

In the Index.cshtml i use this code for the grid definition:


                    <ej-grid id="UsersGrid" datasource="ViewBag.datasource" allow-paging="true" locale="it-IT" action-failure="OnActionFailure">
                        <e-toolbar-settings show-toolbar="true" toolbar-items=@(new List<string>() {"excelExport","wordExport","pdfExport" })>

                        </e-toolbar-settings>
                        <e-page-settings page-size="2" enable-query-string="true"></e-page-settings>
                        <e-datamanager url="http://localhost:5110/api/countries" adaptor="WebApiAdaptor"></e-datamanager>
                        <e-columns>
                            <e-column field="Id" header-text="ID Nazione" text-align="Right" width="75"></e-column>
                            <e-column field="CountryName" header-text="Nazione" text-align="Right" width="75"></e-column>
                            <e-column field="IstatCode" header-text="Codice Isat" text-align="Right" width="75"></e-column>
                            <e-column field="IsoCode" header-text="Codice Iso" text-align="Right" width="75"></e-column>
                            <e-column field="StartDate" header-text="Data Inizio" text-align="Right" width="75"></e-column>
                            <e-column field="EndDate" header-text="Data Fine" text-align="Right" width="75"></e-column>
                        </e-columns>
                    </ej-grid>

This is the Web Api code :
        public object Get()
        {

            DataPage<Country> countries = null;

            using (var uow = _uowProvider.CreateUnitOfWork())
            {
                var repository = uow.GetRepository<Country>();
                var queryString = Request.Query;

                int skip = Convert.ToInt32(queryString["$skip"]);
                int take = Convert.ToInt32(queryString["$top"]);
                skip = skip > 0 ? skip : 1;
                
                countries = _pager.Get(skip, take);

                return new { Items = countries, Count = countries.TotalEntityCount };
            }


        } 

To manage the database access i use Digipolis.DataAccess, and Digipolis.DataAccess.Paging;

The result of this operation is Table empty and the browser console say : TypeError: this.model.currentViewData is undefined.

It's all correct ?
Thanks in advance
Stefano

3 Replies

VA Venkatesh Ayothi Raman Syncfusion Team August 14, 2017 12:41 PM UTC

Hi Stefano, 

Thanks for contacting Syncfusion support. 

We were unable to reproduced the reported issue at our end and we have prepared a sample for your reference which can be download from following link, 
Note: In that sample, we have rendered the Grid using Web API service which is replicates your code example. 

This issue was reproduced when the grid model value is undefined/null. We suspect that you are destroying the Grid model in any case or scenario. If so, provide more details about that as well as could you please share the following details? 
1)      Share the screenshot of issue with expanded details. 
2)      screenshot of network tab while response from server side. 
3)       Scenario for replication procedure. 
4)      Show the first record data details. 
It would be helpful for us to find the problem and provide the better solution as earliest. 

Regards, 
Venkatesh Ayothiraman. 



SC Stefano Capobianco August 15, 2017 08:18 AM UTC

Dear support thx for your help. With your sample i've found the problem. Normally i use in startup.cs the follow mvc initializer:             

services.AddMvc()

                .AddJsonOptions(opts =>

                {

                    // Force Camel Case to JSON

                    opts.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();

                    opts.SerializerSettings.ReferenceLoopHandling =

                               Newtonsoft.Json.ReferenceLoopHandling.Ignore;

                });

The problem was items and not Items according the documentation.

Thx for your help

Stefano Capobianco



VA Venkatesh Ayothi Raman Syncfusion Team August 16, 2017 04:23 AM UTC

Hi Stefano, 

Thanks for the update. 

We are very happy to hear that your requirement is achieved. 

Regards, 
Venkatesh Ayothiraman. 


Loader.
Live Chat Icon For mobile
Up arrow icon