Empty Grid in MVC 6/EF 7

5 posts, 0 answers
  1. Les
    Les avatar
    29 posts
    Member since:
    Feb 2011

    Posted 19 Jan Link to this post

    My grid shows as empty with the following code.

    <!-- jQuery JavaScript -->
    <script src="~/lib/jquery/dist/jquery.js"></script>
    <script src="~/lib/jquery/dist/jquery.min.js"></script>
    <h2>Country Grid</h2>
    @(Html.Kendo().Grid<MACore.Models.Configuration.Geographic.Location.Country>()
        .Name("gridname")
        .Columns(columns => {
            columns.Bound(p => p.CountryID);
            columns.Bound(p => p.Description);
            columns.Bound(p => p.LongDescription);
        })
        .Pageable()
        .Sortable()
        .Scrollable()
        .HtmlAttributes(new { style = "height:550px;" })
        .DataSource(dataSource => dataSource
                .Ajax()
                .Read(read => read.Action("Countries_Read", "Country"))
                .PageSize(20)
         )
    )

    The "Countries_Read" does supply a list of Countries when used with other code....any suggestions? 

  2. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 21 Jan Link to this post

    Hi Les,

    Look in the browser console. Do you see any javascript errors?

    Regards,
    Hristo Valyavicharski
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Les
    Les avatar
    29 posts
    Member since:
    Feb 2011

    Posted 21 Jan in reply to Hristo Valyavicharski Link to this post

    I didn't see any Javascript errors in ie or chrome.

    But i did change my code to the following (using IEnumerable & ViewData) and now the grid is flashing and showing Column Headings repeatedly.

    <!-- jQuery JavaScript -->
    <script src="~/lib/jquery/dist/jquery.js"></script>
    <script src="~/lib/jquery/dist/jquery.min.js"></script>
    <h2>Country Grid</h2>
    @(Html.Kendo().Grid((IEnumerable<MACore.Models.Configuration.Geographic.Location.Country>)ViewData["Country"])
        .Name("GridCountry")
        .Columns(columns => {
            columns.Bound(p => p.Description);
            columns.Bound(p => p.LongDescription);
        })
    )

  5. Lee
    Lee avatar
    20 posts
    Member since:
    Jun 2014

    Posted 22 Jan in reply to Hristo Valyavicharski Link to this post

    I'm having identical issue.  I don't have any errors in the console.    My Controller code is as such:

    public IActionResult ManpowerUserPermissions2()
    {
    SetupViewBag();
    return View();
    }
    public JsonResult GetUserPermissions([DataSourceRequest] DataSourceRequest request)
    {
    SetupViewBag();
    var _perms = _repository.GetAllManpowerPermissions();
    var _result = _perms.ToDataSourceResult(request);
    return Json(_result);

     In my View I've following code to setup my grid:

    @(Html.Kendo().Grid<ManpowerForecast.Web.Models.ManpowerUserPermission>()
    .Name("grid")
    .Columns(columns =>
    {
    columns.Bound(c => c.User.DisplayName)
    .Width(250);
    columns.Bound(c => c.Role.RoleID)
    .Width(100);
    columns.Bound(c => c.Role.RoleDesc)
    .Width(240);
    })
    .HtmlAttributes(new { style = "height: 550px;" })
    .Scrollable()
    .Groupable()
    .Sortable()
    .Pageable(pageable => pageable
    .Refresh(true)
    .PageSizes(true)
    .ButtonCount(5))
    .DataSource(dataSource => dataSource
    .Ajax()
    .Read(read => read.Action("GetUserPermissions", "Manpower"))
    .PageSize(20)
    )
    .Deferred()
    )
    @section scripts {
    <script type="text/javascript">
    $(document).ready(function () {
    @Html.Kendo().DeferredScriptsFor("grid", false)
    });
    </script>
    }

     If I step through code in debugger I can see that the getUserPermissions is returning 1 row of data.

    Consequently I'm using Asp.net 5 with clr x64, 1.0.0-rc1-final

  6. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 25 Jan Link to this post

    Hi, 

    Your code looks good. Please attach sample project, so we can debug your code. Then we would be able to tell you how to proceed.

    Thanks.

    Regards,
    Hristo Valyavicharski
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for ASP.NET MVC is VS 2017 Ready