Javascript error on grid: Cannot read property 'slice' of undefined

1 Answer 1809 Views
Grid
Jay
Top achievements
Rank 1
Iron
Iron
Jay asked on 21 May 2021, 08:33 PM

I have a simple grid setup with the datasource is returning a list.

  <kendo-grid name="grid" height="550">
      <datasource type="DataSourceTagHelperType.WebApi" page-size="5">
          <transport>
               <read url="@Url.Action("GetSchedule", "Home")" />
          </transport>
      </datasource>
      <columns>
           <column field="SalesRepName" title="Sales Agent" />               
           <column field="Shift" title="Shift" />
           <column field="Phone" title="Phone" />
      </columns>
 </kendo-grid>

  public ActionResult GetSchedule([DataSourceRequest] DataSourceRequest request)
        {
            // get scheduled sales rep.
            var result = _idb.RetrieveCurrentSchedule("LSL", "NH");

            var dsResult = result.ToDataSourceResult(request);

            return Json(dsResult);

        }
bundle.js:1 Uncaught TypeError: Cannot read property 'slice' of undefined

 

1 Answer, 1 is accepted

Sort by
0
Mihaela
Telerik team
answered on 26 May 2021, 02:12 PM

Hi Jay,

Thank you for the provided code snippets.

By design, this error occurs during the binding of the widget to the data source. Most probably the variable "result" does not represent an array of data items, which is returned as a JSON object by the "GetSchedule" Action method.

I would suggest debugging the "Read" Action method to check if the variable "result" contains an array of items. 

In addition, I have prepared a demo project (attached). Please modify it based on the behavior you are experiencing and send it back in the thread. I will test it locally and follow up with the respective suggestions.

Thank you for your cooperation.

 

Regards, Mihaela Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Jay
Top achievements
Rank 1
Iron
Iron
commented on 26 May 2021, 02:36 PM

Thanks, for the response. yes I checked that the result, it is an array. I fixed the problem by creating a new web app using the Telerik grid project template. The grid is now working. I updated Telerik through your control panel but Visual studio did not have the asp.net core extensions installed so i tried to manually add Telerik asp.net core UI pieces to my asp.net core project and I think something is messed up. So I downloaded the asp.net core msi installer from your site. After installing it I now have the Telerik asp.net core project template.
Tags
Grid
Asked by
Jay
Top achievements
Rank 1
Iron
Iron
Answers by
Mihaela
Telerik team
Share this question
or