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

[Solved] refresh kendo grid is getting an error.

1 Answer 205 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jeffrey
Top achievements
Rank 1
Jeffrey asked on 30 Sep 2014, 02:45 PM
I am getting an error when i try to refresh the data source of my grid.

Here is the code...

 $(function () {
        setInterval(function () {
               
                $('#eventLog').data('kendoGrid').dataSource.page(1);
                $('#eventLog').data('kendoGrid').dataSource.read();

           

        },
        60000);
    });

0x800a138f - Microsoft JScript runtime error: Unable to get value of the property 'dataSource': object is null or undefined

The grid code is this...


@(Html.Kendo().Grid(Model.DailyLogEventList)
                  .Name("dailyLogGrid")
                  .HtmlAttributes(new { style = "height: 250px" })
                      .Events(events => events.DataBound("dataBound"))
                      .DataSource(dataSource => dataSource
                          .Ajax()
                          .ServerOperation(false)
                          .PageSize(8)
                          .Read(read => read.Action("DailyLogList_Read", "DailyLog")))
                  .Columns(columns =>
                  {
                      columns.Bound(x => x.IncidentAttached)
                          .ClientTemplate("<a href='" + Url.Action("index", "IncidentReport", new { area = "DailyLog", logId = "#=LogId#'>" }) + "#= IncidentAttached ? '<img src=\"/Images/icon_edit.gif\" />' : '' #" + "</a>")
                          .Width(10)
                          .Title("")
                          .Filterable(false);
                      columns.Bound(p => p.Status).ClientTemplate("# if(Status === 'OPEN') { #" +
                        "<img src='/images/open.png' />" +
                        "# } else if(Status === 'CLOSED'){ #" +
                        "<img src='/images/closed.png' />" +
                        "# } else { #" +
                        "<img src='/images/10days.png' />" +
                        "# } #")
                        .Width(10)
                        .Title("")
                        .Filterable(false);
                      columns.Bound(x => x.LogId).Width(25).Title("Id");
                      columns.Bound(x => x.StartDate).Title("Started").Format("{0:MM/dd/yyyy HH:mm}").Width(40).Sortable(true);
                      columns.Bound(x => x.EventDescription).Title("Event").Width(60).Filterable(filterable => filterable.UI("eventDescFilter"));
                      columns.Bound(x => x.Comments).Title("Comments").Width(63);
                      columns.Bound(x => x.RespondingOfficers).Title("Officer(s)").Width(70);
                      columns.Command(command => command.Custom("Edit").Click("loadDataForEdit")).Width(20);
                  })
                  .Pageable()
                  .Selectable(s => s.Mode(GridSelectionMode.Single))
                  .Filterable()
                  .Scrollable()
)

1 Answer, 1 is accepted

Sort by
0
Kiril Nikolov
Telerik team
answered on 02 Oct 2014, 06:53 AM
Hi Jeffrey,

I can see that the name of the grid is:

 .Name("dailyLogGrid")

while you select the grid with:

 $('#eventLog').data('kendoGrid')

Therefore a reference to the widget cannot be established. I would suggest you use the Grids name in your JavaScript code and try again.

Regards,
Kiril Nikolov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Jeffrey
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
Share this question
or