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

ASP.NET MVC3 Can not get data displayed in Kendo grid

1 Answer 92 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dalibor
Top achievements
Rank 1
Dalibor asked on 09 Jul 2013, 11:04 AM
After spending entire morning trying to get some data to be data displayed in Kendo grid I am getting pretty annoyed.
With this html (generated by Kendo MVC wrapper):

<div class="k-widget k-grid" id="grid_AitTodaySectionEntity"><table><colgroup><col /><col /><col /><col /><col /><col /><col /></colgroup><thead class="k-grid-header"><tr><th class="k-header k-filterable" data-field="Caption" data-title="Caption" scope="col"><a class="k-grid-filter"><span class="k-icon k-filter"></span></a><a class="k-link" href="/Grid/Get?Type=AitTodaySectionEntity&grid_AitTodaySectionEntity-sort=Caption-asc">Caption</a></th><th class="k-header k-filterable" data-field="DefaultRows" data-title="Default Rows" scope="col"><a class="k-grid-filter"><span class="k-icon k-filter"></span></a><a class="k-link" href="/Grid/Get?Type=AitTodaySectionEntity&grid_AitTodaySectionEntity-sort=DefaultRows-asc">Default Rows</a></th><th class="k-header k-filterable" data-field="Id" data-title="Id" scope="col"><a class="k-grid-filter"><span class="k-icon k-filter"></span></a><a class="k-link" href="/Grid/Get?Type=AitTodaySectionEntity&grid_AitTodaySectionEntity-sort=Id-asc">Id</a></th><th class="k-header k-filterable" data-field="ModuleId" data-title="Module Id" scope="col"><a class="k-grid-filter"><span class="k-icon k-filter"></span></a><a class="k-link" href="/Grid/Get?Type=AitTodaySectionEntity&grid_AitTodaySectionEntity-sort=ModuleId-asc">Module Id</a></th><th class="k-header k-filterable" data-field="TodaySection" data-title="Today Section" scope="col"><a class="k-grid-filter"><span class="k-icon k-filter"></span></a><a class="k-link" href="/Grid/Get?Type=AitTodaySectionEntity&grid_AitTodaySectionEntity-sort=TodaySection-asc">Today Section</a></th><th class="k-header k-filterable" data-field="IsNew" data-title="Is New" scope="col"><a class="k-grid-filter"><span class="k-icon k-filter"></span></a><a class="k-link" href="/Grid/Get?Type=AitTodaySectionEntity&grid_AitTodaySectionEntity-sort=IsNew-asc">Is New</a></th><th class="k-header k-filterable" data-field="IsDirty" data-title="Is Dirty" scope="col"><a class="k-grid-filter"><span class="k-icon k-filter"></span></a><a class="k-link" href="/Grid/Get?Type=AitTodaySectionEntity&grid_AitTodaySectionEntity-sort=IsDirty-asc">Is Dirty</a></th></tr></thead><tbody><tr class="t-no-data"><td colspan="7"></td></tr></tbody></table><div class="k-pager-wrap k-grid-pager"><a class="k-link k-state-disabled" data-page="1" href="#" title="Go to the first page"><span class="k-icon k-i-seek-w">seek-w</span></a><a class="k-link k-state-disabled" data-page="0" href="#" title="Go to the previous page"><span class="k-icon k-i-arrow-w">arrow-w</span></a><ul class="k-pager-numbers k-reset"><li><span class="k-state-selected" data-page="1">1</span></li></ul><a class="k-link k-state-disabled" data-page="2" href="#" title="Go to the next page"><span class="k-icon k-i-arrow-e">arrow-e</span></a><a class="k-link k-state-disabled" data-page="1" href="#" title="Go to the last page"><span class="k-icon k-i-seek-e">seek-e</span></a><span class="k-pager-info k-label">No items to display</span></div></div><script>
    jQuery(function(){jQuery("#grid_AitTodaySectionEntity").kendoGrid({"columns":[{"title":"Caption","field":"Caption","filterable":{},"encoded":true},{"title":"Default Rows","field":"DefaultRows","filterable":{},"encoded":true},{"title":"Id","field":"Id","filterable":{},"encoded":true},{"title":"Module Id","field":"ModuleId","filterable":{},"encoded":true},{"title":"Today Section","field":"TodaySection","filterable":{},"encoded":true},{"title":"Is New","field":"IsNew","filterable":{},"encoded":true},{"title":"Is Dirty","field":"IsDirty","filterable":{},"encoded":true}],"pageable":{"buttonCount":10},"sortable":true,"filterable":true,"scrollable":false,"dataSource":{"transport":{"prefix":"","read":{"url":"/Grid/Get?Type=AitTodaySectionEntity"}},"pageSize":10,"page":1,"total":0,"serverPaging":true,"serverSorting":true,"serverFiltering":true,"serverGrouping":true,"serverAggregates":true,"type":"aspnetmvc-ajax","filter":[],"schema":{"data":"Data","total":"Total","errors":"Errors","model":{"fields":{"Caption":{"type":"string"},"DefaultRows":{"type":"number","defaultValue":null},"Id":{"type":"number"},"ModuleId":{"type":"number"},"TodaySection":{"type":"string"},"ModModule":{"type":"object"},"Fields":{"type":"object"},"IsNew":{"type":"boolean"},"IsDirty":{"type":"boolean"},"ActiveContext":{"type":"object"},"ConcurrencyPredicateFactoryToUse":{"type":"object"},"AuthorizerToUse":{"type":"object"},"AuditorToUse":{"type":"object"},"Validator":{"type":"object"}}}}}});});
</script>

And the result of the call to the controller:
{
  "$id": "1",
  "Data": [
    {
      "$id": "2",
      "Caption": "Calendar",
      "DefaultRows": 5,
      "Id": 1,
      "ModuleId": 9,
      "TodaySection": "CALENDER"
    },
    {
      "$id": "3",
      "Caption": "Repairs",
      "DefaultRows": 999,
      "Id": 2,
      "ModuleId": 2,
      "TodaySection": "EXP_REPAIRS"
    },
    {
      "$id": "4",
      "Caption": "Maintenance",
      "DefaultRows": 999,
      "Id": 3,
      "ModuleId": 2,
      "TodaySection": "EXP_MAINTENANCE"
    },
    {
      "$id": "5",
      "Caption": "CPI",
      "DefaultRows": 999,
      "Id": 4,
      "ModuleId": 3,
      "TodaySection": "TODAY.CIP"
    },
    {
      "$id": "6",
      "Caption": "Notifications",
      "DefaultRows": 999,
      "Id": 5,
      "ModuleId": 1,
      "TodaySection": "EXP_NOTIFICATIONS"
    },
    {
      "$id": "7",
      "Caption": "Tasks",
      "DefaultRows": 999,
      "Id": 6,
      "ModuleId": 4,
      "TodaySection": "EXP_TASKS"
    },
    {
      "$id": "8",
      "Caption": "Support cases",
      "DefaultRows": 999,
      "Id": 7,
      "ModuleId": 5,
      "TodaySection": "EXP_SUPPORT"
    },
    {
      "$id": "9",
      "Caption": "Call ToDo",
      "DefaultRows": 999,
      "Id": 8,
      "ModuleId": 12,
      "TodaySection": "CALL_TODO"
    },
    {
      "$id": "10",
      "Caption": "My VoiceMail Messages",
      "DefaultRows": 999,
      "Id": 9,
      "ModuleId": 12,
      "TodaySection": "MY_VOICEMAIL"
    },
    {
      "$id": "11",
      "Caption": "Today Call-Log",
      "DefaultRows": 999,
      "Id": 10,
      "ModuleId": 12,
      "TodaySection": "TODAY_CALL_LOG"
    },
    {
      "$id": "12",
      "Caption": "My Discussions",
      "DefaultRows": 999,
      "Id": 11,
      "ModuleId": 15,
      "TodaySection": "TODAY_MY_DISCUSSION"
    },
    {
      "$id": "13",
      "Caption": "Legal Control appointments",
      "DefaultRows": 20,
      "Id": 12,
      "ModuleId": 19,
      "TodaySection": "LC_APPOINTMENTS"
    },
    {
      "$id": "14",
      "Caption": "Repairs2",
      "DefaultRows": 999,
      "Id": 13,
      "ModuleId": 20,
      "TodaySection": "EXP_REPAIRS2"
    },
    {
      "$id": "15",
      "Caption": "Maintenance2",
      "DefaultRows": 999,
      "Id": 14,
      "ModuleId": 20,
      "TodaySection": "EXP_MAINTENANCE2"
    },
    {
      "$id": "16",
      "Caption": "CPI2",
      "DefaultRows": 999,
      "Id": 15,
      "ModuleId": 22,
      "TodaySection": "TODAY.CIP2"
    },
    {
      "$id": "17",
      "Caption": "Overdue Maintenances2",
      "DefaultRows": 999,
      "Id": 16,
      "ModuleId": 20,
      "TodaySection": "EXP_MAIN_OVER2"
    },
    {
      "$id": "18",
      "Caption": "Top CIPs",
      "DefaultRows": 50,
      "Id": 17,
      "ModuleId": 22,
      "TodaySection": "TODAY.CIP.TOP"
    },
    {
      "$id": "19",
      "Caption": "Measures",
      "DefaultRows": 999,
      "Id": 18,
      "ModuleId": 23,
      "TodaySection": "TODAY.MEASURES"
    },
    {
      "$id": "20",
      "Caption": "Under min. stock",
      "DefaultRows": 999,
      "Id": 19,
      "ModuleId": 8,
      "TodaySection": "TODAY.STOCK_UNDER_MINIMUM"
    }
  ],
  "Total": 19,
  "AggregateResults": null,
  "Errors": null
}
I don't get anything. 
The controller does get called and the content is transfered (see atached image). But nothing is showing up.
I have no idea how to determine what could be wrong!!!!

Here is the controller method:

Function [Get](type As String, <Kendo.Mvc.UI.DataSourceRequest()> request As DataSourceRequest) As ActionResult
    Dim result As Object
    Using daa As New DataAccessAdapter(ConfigurationManager.AppSettings("ConnectionString"))
        Dim linq As New LinqMetaData(daa)
        Dim assets As IQueryable(Of AitTodaySectionEntity) = linq.AitTodaySection
        result = assets.ToDataSourceResult(request)
    End Using
    Dim json As New JsonNetResult
    json.Data = result
    Return json
End Function

<div class="k-widget k-grid" id="grid_AitTodaySectionEntity"><table><colgroup><col /><col /><col /><col /><col /><col /><col /></colgroup><thead class="k-grid-header"><tr><th class="k-header k-filterable" data-field="Caption" data-title="Caption" scope="col"><a class="k-grid-filter"><span class="k-icon k-filter"></span></a><a class="k-link" href="/Grid/Get?Type=AitTodaySectionEntity&amp;grid_AitTodaySectionEntity-sort=Caption-asc">Caption</a></th><th class="k-header k-filterable" data-field="DefaultRows" data-title="Default Rows" scope="col"><a class="k-grid-filter"><span class="k-icon k-filter"></span></a><a class="k-link" href="/Grid/Get?Type=AitTodaySectionEntity&amp;grid_AitTodaySectionEntity-sort=DefaultRows-asc">Default Rows</a></th><th class="k-header k-filterable" data-field="Id" data-title="Id" scope="col"><a class="k-grid-filter"><span class="k-icon k-filter"></span></a><a class="k-link" href="/Grid/Get?Type=AitTodaySectionEntity&amp;grid_AitTodaySectionEntity-sort=Id-asc">Id</a></th><th class="k-header k-filterable" data-field="ModuleId" data-title="Module Id" scope="col"><a class="k-grid-filter"><span class="k-icon k-filter"></span></a><a class="k-link" href="/Grid/Get?Type=AitTodaySectionEntity&amp;grid_AitTodaySectionEntity-sort=ModuleId-asc">Module Id</a></th><th class="k-header k-filterable" data-field="TodaySection" data-title="Today Section" scope="col"><a class="k-grid-filter"><span class="k-icon k-filter"></span></a><a class="k-link" href="/Grid/Get?Type=AitTodaySectionEntity&amp;grid_AitTodaySectionEntity-sort=TodaySection-asc">Today Section</a></th><th class="k-header k-filterable" data-field="IsNew" data-title="Is New" scope="col"><a class="k-grid-filter"><span class="k-icon k-filter"></span></a><a class="k-link" href="/Grid/Get?Type=AitTodaySectionEntity&amp;grid_AitTodaySectionEntity-sort=IsNew-asc">Is New</a></th><th class="k-header k-filterable" data-field="IsDirty" data-title="Is Dirty" scope="col"><a class="k-grid-filter"><span class="k-icon k-filter"></span></a><a class="k-link" href="/Grid/Get?Type=AitTodaySectionEntity&amp;grid_AitTodaySectionEntity-sort=IsDirty-asc">Is Dirty</a></th></tr></thead><tbody><tr class="t-no-data"><td colspan="7"></td></tr></tbody></table><div class="k-pager-wrap k-grid-pager"><a class="k-link k-state-disabled" data-page="1" href="#" title="Go to the first page"><span class="k-icon k-i-seek-w">seek-w</span></a><a class="k-link k-state-disabled" data-page="0" href="#" title="Go to the previous page"><span class="k-icon k-i-arrow-w">arrow-w</span></a><ul class="k-pager-numbers k-reset"><li><span class="k-state-selected" data-page="1">1</span></li></ul><a class="k-link k-state-disabled" data-page="2" href="#" title="Go to the next page"><span class="k-icon k-i-arrow-e">arrow-e</span></a><a class="k-link k-state-disabled" data-page="1" href="#" title="Go to the last page"><span class="k-icon k-i-seek-e">seek-e</span></a><span class="k-pager-info k-label">No items to display</span></div></div><script>
jQuery(function(){jQuery("#grid_AitTodaySectionEntity").kendoGrid({"columns":[{"title":"Caption","field":"Caption","filterable":{},"encoded":true},{"title":"Default Rows","field":"DefaultRows","filterable":{},"encoded":true},{"title":"Id","field":"Id","filterable":{},"encoded":true},{"title":"Module Id","field":"ModuleId","filterable":{},"encoded":true},{"title":"Today Section","field":"TodaySection","filterable":{},"encoded":true},{"title":"Is New","field":"IsNew","filterable":{},"encoded":true},{"title":"Is Dirty","field":"IsDirty","filterable":{},"encoded":true}],"pageable":{"buttonCount":10},"sortable":true,"filterable":true,"scrollable":false,"dataSource":{"transport":{"prefix":"","read":{"url":"/Grid/Get?Type=AitTodaySectionEntity"}},"pageSize":10,"page":1,"total":0,"serverPaging":true,"serverSorting":true,"serverFiltering":true,"serverGrouping":true,"serverAggregates":true,"type":"aspnetmvc-ajax","filter":[],"schema":{"data":"Data","total":"Total","errors":"Errors","model":{"fields":{"Caption":{"type":"string"},"DefaultRows":{"type":"number","defaultValue":null},"Id":{"type":"number"},"ModuleId":{"type":"number"},"TodaySection":{"type":"string"},"ModModule":{"type":"object"},"Fields":{"type":"object"},"IsNew":{"type":"boolean"},"IsDirty":{"type":"boolean"},"ActiveContext":{"type":"object"},"ConcurrencyPredicateFactoryToUse":{"type":"object"},"AuthorizerToUse":{"type":"object"},"AuditorToUse":{"type":"object"},"Validator":{"type":"object"}}}}}});});
</script>

1 Answer, 1 is accepted

Sort by
0
Accepted
Dalibor
Top achievements
Rank 1
answered on 09 Jul 2013, 04:34 PM
Found the problem. I was not setting the correct content type for the JSON data.
Tags
Grid
Asked by
Dalibor
Top achievements
Rank 1
Answers by
Dalibor
Top achievements
Rank 1
Share this question
or