Unable to bind data using Kendo ui grid


Natalaran Nagarazugari

This is my action method

 public ActionResult Kendo([DataSourceRequest]DataSourceRequest request )
    {
        var emp = EmployeeManager.GetAllEmployees();

        DataSourceResult result = emp.ToDataSourceResult(request);
        return Json(result);
    }


This is the grid code I got from the official website

@model IEnumerable<MyProject.Web.Models.EmployeeViewModels.EmployeeViewModel>

@using Kendo.Mvc.UI;

@(Html.Kendo().Grid<TalentPro.Employees.Employee>()
      .Name("grid")
      .DataSource(dataSource => dataSource //Configure the Grid data source.
          .Ajax() //Specify that Ajax binding is used.
          .Read(read => read.Action("Kendo", "Home")
          ) //Set the action method which will return the data in JSON format.

       )
      .Columns(columns =>
      {
          //Create a column bound to the ProductID property.
          columns.Bound(product => product.Id);
          //Create a column bound to the ProductName property.
          columns.Bound(product => product.FirstName);
          //Create a column bound to the UnitsInStock property.
          columns.Bound(product => product.LastName);
          columns.Bound(product => product.EmailId);
          columns.Bound(product => product.PhoneNumber);
      })
      .Pageable() // Enable paging
      .Sortable() // Enable sorting

I checked the official documentation and it helped me to integrate Kendo ui with my Asp.net core project . But I don't know where I am going wrong, it is not binding the data with the grid.

I've been trying multiple ways but to no avail. Can anyone help me with this problem.
Thanks in advance.

Natalaran Nagarazugari

Finally got the solution These are the changes I made

  1. Change ActionResult to JsonResult
  2. Added the following line to startup.cs:
    ".AddJsonOptions(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver());"
    thank you coby

Related


Unable to bind data using Kendo ui grid

Natalaran Nagarazugari This is my action method public ActionResult Kendo([DataSourceRequest]DataSourceRequest request ) { var emp = EmployeeManager.GetAllEmployees(); DataSourceResult result = emp.ToDataSourceResult(request); ret

Unable to bind data using Kendo ui grid

Natalaran Nagarazugari This is my action method public ActionResult Kendo([DataSourceRequest]DataSourceRequest request ) { var emp = EmployeeManager.GetAllEmployees(); DataSourceResult result = emp.ToDataSourceResult(request); ret

Unable to bind data using Kendo ui grid

Natalaran Nagarazugari This is my action method public ActionResult Kendo([DataSourceRequest]DataSourceRequest request ) { var emp = EmployeeManager.GetAllEmployees(); DataSourceResult result = emp.ToDataSourceResult(request); ret

Bind data to Kendo UI template using HTML table as data source

Charlie Ouyang| I have created a service that will return a set of HTML tables based on request parameters. Currently, I am returning the data (HTML page) as a string. Example output is as follows: <!DOCTYPE html> <html> <head> <META http-equiv="Conte

Unable to bind data to Kendo Scheduler

Chiapa I have this Kendo Scheduler showing in the view but no data. The scheduler on the view: @(Html.Kendo().Scheduler<ProjName.Models.ScheduleInspectionModel>() .Name("scheduler") .Views(views => { views.DayView(); views.WorkWeekV

Unable to bind data to Kendo Scheduler

Chiapa I have this Kendo Scheduler showing in the view but no data. The scheduler on the view: @(Html.Kendo().Scheduler<ProjName.Models.ScheduleInspectionModel>() .Name("scheduler") .Views(views => { views.DayView(); views.WorkWeekV

Sort Grid data in Kendo UI Grid

Masood I want to sort the retrieved data to the description field, but I can't sort it. UI code: Display data correctly var gridDataSource = new kendo.data.DataSource({ autoSync: true, data: transformation.Activities, schema: { model: {

Unable to set Kendo UI grid datasource

aw04 I'm complementing a working Kendo UI grid to allow it to update based on an ID passed in from a textbox. I'm calling my controller from ajax and everything works as expected until I try to create kendo.data.DataSource()for my grid inside ajax success . It

Unable to style first row in Kendo UI grid

Peaceful Thought I want to style rows in kendo ui grid. Here is my code: //grid @(Html.Kendo().Grid<Model>() .Name("gridModel") .HtmlAttributes(new { @class = "table" }) .DataSource(x => x.Ajax() .Read("ReadD

Bind Kendo grid to complex data source

username I have a div which will be converted to a Kendo grid in Jquery. divSearchGrid.kendoGrid({ dataSource: { transport: { read: function (options) { var webMethod = "Portal.aspx/DisplayNotes"; $.ajax

Unable to bind grid to viewmodel - no data in grid

w0051977 See the XAML below: <?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:App1" x:Cla

Unable to bind grid to viewmodel - no data in grid

w0051977 See the XAML below: <?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:App1" x:Cla

Bind sharepoint data to Kendo pivot grid via Kendo DLL or REST

saber tabatabaee Shado I have many lists in sharepoint that collect information from other lists by lookup fields. We have more than 30 reports connected to lists and displaying data in kendo grid . But this article has something complicated about the kendo pi

Bind sharepoint data to Kendo pivot grid via Kendo DLL or REST

saber tabatabaee Shado I have many lists in sharepoint that collect information from other lists by lookup fields. We have more than 30 reports connected to lists and displaying data in kendo grid . But this article has something complicated about the kendo pi

Bind sharepoint data to Kendo pivot grid via Kendo DLL or REST

saber tabatabaee Shado I have many lists in sharepoint that collect information from other lists by lookup fields. We have more than 30 reports connected to lists and displaying data in kendo grid . But this article has something complicated about the kendo pi

Dynamically bind XML data to Kendo ui menu

Brandonk I am trying to dynamically create a Kendo menu using XML data. I am reading data from menu_data.xml. How to format data in xml file into vertical menu. Here is my code below: xml-menu.html <!doctype html> <html> <head> <title></title> <link href="http

Kendo UI Grid, sorting data source groups

Ben Cameron I have a page with a kendo grid on it. It is calling ajaz web request to get its data. After the data is returned, it will be grouped on the front end. The problem I'm having is sorting the groups. What's the best way to do this? My MVC view code l

Export data from Kendo-UI grid

User 1451111 The KendoUI grid code in my app is declarative like this: <kendo-grid id="myGrid" options="mainGridOptions"> <kendoGridToolbarTemplate> <button kendoGridExcelCommand>Export to Excel</button> <kendo-grid-excel fileName="Gri

kendo ui grid data not showing from php

username I want to display data into my kendo grid. I am using basic php mysql to return results from database. Here is my kendo javascript code. <script> $(document).ready(function () { $("#grid").kendoGrid({ dataSource: {

Kendo UI Grid pass data to another form

Nixon I have this demo related to my situation , how to bind additional data dataSourceinto my popup form. If, a popup form will appear outletType = rest. thanks for your help. Dojo Demo don't vote for me You don't need to set extra data , data from all data s

How to manually load data in Kendo UI grid

Taversi I have a kendo ui grid. I want to load the grid manually. For example, when my page loads, the grid doesn't load, but when I click the button, the data loads into the grid. what should I do? thanks. Johnny Hong Kong Automatic loading from the grid's da