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

Empty Grid in MVC 6/EF 7

4 Answers 91 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Les
Top achievements
Rank 1
Les asked on 20 Jan 2016, 02:46 AM

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? 

4 Answers, 1 is accepted

Sort by
0
Hristo Valyavicharski
Telerik team
answered on 21 Jan 2016, 01:40 PM
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
0
Les
Top achievements
Rank 1
answered on 21 Jan 2016, 07:34 PM

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

0
Lee
Top achievements
Rank 1
answered on 22 Jan 2016, 07:56 PM

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

0
Hristo Valyavicharski
Telerik team
answered on 25 Jan 2016, 04:31 PM
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
Tags
Grid
Asked by
Les
Top achievements
Rank 1
Answers by
Hristo Valyavicharski
Telerik team
Les
Top achievements
Rank 1
Lee
Top achievements
Rank 1
Share this question
or