This is a migrated thread and some comments may be shown as answers.

Kendo Grid DataSource Not calling the action on page load

1 Answer 635 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Natarajan
Top achievements
Rank 1
Natarajan asked on 06 Feb 2018, 04:24 PM

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);
        }

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 08 Feb 2018, 07:48 AM
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.
Tags
Data Source
Asked by
Natarajan
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or