0

I want to show users in a Kendo Grid. Here is my Controller:

public class UserController : Controller
    {
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Users_Read([DataSourceRequest]DataSourceRequest request)
        {
            using (var rahatWeb = new RahatWebEntities())
            {
                IQueryable<User> users = rahatWeb.Users;
                DataSourceResult result = users.ToDataSourceResult(request);
                return Json(result, JsonRequestBehavior.AllowGet);
            }
        }
    }

Here is my View:

@{
    ViewBag.Title = "";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@(Html.Kendo().Grid<RahatWeb.Models.User>()
          .Name("grid")
          .Columns(columns =>
          {
              columns.Bound(user => user.Id);
              columns.Bound(user => user.FirstName);
              columns.Bound(user => user.LastName);
          })
          .DataSource(dataSource => dataSource
              .Ajax()
              .Read(read => read.Action("Users_Read", "User"))
           )
          .Pageable()
          .Sortable()
)

The problem is that no data is shown in Grid. How can I solve the issue?

6
  • 2
    are you hitting the controller, is the controller blowing up? Is it returning data? Does it return the data in the format expected by the grid? Have you tried debugging anything? Commented Sep 5, 2016 at 8:53
  • Yes I requested the Users_Read Action manually and JSON result was returned data. When I put a breakpoint on Users_Read Action and request the Index Action then the Grid is shown normally but without any data into it. Commented Sep 5, 2016 at 9:13
  • 1
    Have you included kendo.aspnetmvc.min.js in your layout? Also, hit F12 in your browser and check the console for any client-side errors. Commented Sep 5, 2016 at 12:21
  • @mrmashal, Thank you so much. You are correct. The problem was this. Thank you. Commented Sep 5, 2016 at 12:24
  • 1
    @MohsenJafari Good to hear that! I'll post my comment as an answer so you can mark this question accepted :) Commented Sep 5, 2016 at 13:06

1 Answer 1

1

Have you included kendo.aspnetmvc.min.js in your layout? Also, hit F12 in your browser and check the console for any client-side errors.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.