Kendo Grid DataSource Not calling the action on page load

2 posts, 0 answers
  1. Natarajan
    Natarajan avatar
    1 posts
    Member since:
    Jan 2018

    Posted 06 Feb Link to this post

    below is the kendo grid which is not calling the mentioned action/controller on page load hence the data to the grid is empty..

    HTML Code

    <div class="container-fluid">
            <div class="row">
                <div class="col-xs-18 col-md-12">
                    @(Html.Kendo().Grid<abcxksdkd.Models.DisplayUserModel>
                ()
                .Name("grid")
                .Columns(columns =>
                {
                    columns.Bound(p => p.UserName).Filterable(false);
                    columns.Bound(p => p.UserRole);
                    columns.Bound(p => p.Email);
                    columns.Bound(p => p.isLocked);
                })
                .Pageable()
                .Sortable()
                .Scrollable()
                .Filterable()
                .HtmlAttributes(new { style = "height:550px;" })
                .DataSource(dataSource => dataSource
                .Ajax()
                .PageSize(20)
                .Read(read => read.Action("Orders_Read", "Admin"))
                )
                    )
                </div>
            </div>
        </div>

     

    CONTROLLER CODE

     

    public ActionResult Orders_Read([DataSourceRequest]DataSourceRequest request)
            {
                Model user = new Model();
               
                foreach (var a in DbContext.Users)
                {
                    user.UserName = a.Name;
                    user.UserRole = Roles.ToString();
                    user.isLocked = a.Lockout;
                    user.Email = a.mail;
                }
                var result = Enumerable.Range(0, 10).Select(i => new Model
                {
                    UserName = user.UserName,
                    Email = user.Email,
                    isLocked = user.isLocked,
                    UserRole = user.UserRole
                });
                return Json(result.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
            }

  2. Stefan
    Admin
    Stefan avatar
    1961 posts

    Posted 08 Feb Link to this post

    Hello, Natarajan,

    Thank you for the provided code.

    After inspecting it all looks good. The only thing that may be causing the issue is that the Controller is not called AdminController.

    When the page is loaded the Grid should make a request and I can suggest inspecting in the network tab the URL to which the request is made. If there are no requests made inside the network tab, please provide an example as the issue could be caused by a factor which we are overlooking at this moment.

    Regards,
    Stefan
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top