Ungaught TypeError. Can not read properties of undefined (reading 'data')

1 Answer 238 Views
Button Grid
Mihail
Top achievements
Rank 1
Mihail asked on 23 Jan 2022, 06:40 PM

Hi there! In the code below when i reach $("#bans-grid").kendoGrid() function i get the type of error i've mentioned in the title. I don't understand why. Any help will be appreciated!


 $("#saveButton").kendoButton({
              click: function() {

                  var channelsData = $("#bans-grid").data().kendoGrid.dataSource.view();
                  var channelsDataJson = JSON.stringify(channelsData);

                      $("#bans-grid").kendoGrid({
                          dataSource: {
                                 transport: {
                                     update: {
                                         data: channelsDataJson,
                                         url: "/bg/NotosPrime/Bans/BanChannels",
                                         type: "PUT"
                                       }
                                     },
                                     schema: {
                                         model: {
                                             id: "Id"
                                         }
                                     }
                                }
                             });
                             $("#bans-grid").dataSource.sync();
                }
            });

1 Answer, 1 is accepted

Sort by
0
Petar
Telerik team
answered on 25 Jan 2022, 07:43 AM

Hi Mihail,

In the shared code there are two lines on which the Grid should throw errors. 

The first line is this one:

var channelsData = $("#bans-grid").data().kendoGrid.dataSource.view();

The above should be changed to this one:

var channelsData = $("#bans-grid").data("kendoGrid").dataSource.view();

The next line you can update is this one:

$("#bans-grid").dataSource.sync();

The above should be changed to:

$("#bans-grid").data("kendoGrid").dataSource.sync();

Here is a Dojo example demonstrating the usage of the first change suggested above. 

I hope the above details will help you achieve what you need in your application.

Regards,
Petar
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Button Grid
Asked by
Mihail
Top achievements
Rank 1
Answers by
Petar
Telerik team
Share this question
or