Cannot read property 'value' of undefined

1 Answer 10465 Views
Grid
Steve
Top achievements
Rank 1
Steve asked on 11 Feb 2016, 05:58 AM

Hi All,

I have a page with grid and command button that popup a kendoWindow (partial view) and parent viewModel is passed to the partial view.  Inside the kendoWindow, there is another grid which the user can select and delete the row.  The partial view and script below always give me this error  'TypeError: Cannot read property 'value' of undefined' and I can't figure out why.  Is there a way to solve this issue?  and applying kendo.bind in the partial view(the javascript below) cause more problems.

HTML

<div id="notes-dialog" title="Notes" style="display: none">
    <div id="grid"></div>
</div>

 

Javascript

  function display() {
        ds = new kendo.data.DataSource({
            pageSize: 20,
            data: viewModel.CurrentlyDisplayedNotes,
            autoSync: true,
            schema: {
                model: {
                    id: "Id",
                    fields: {
                        Id:{editable: false},
                        Notes: { editable: true, type:"string" }
                    }
                }
            }
        });

        var gridNotes = $("#grid").kendoGrid({
            dataSource: ds,
            pageable: true,
            resizable: true,
            height: 365,
            toolbar: [{ text: "Add", click: addNote }],
            columns: [
              {
                field: "Notes", title: "Notes"                 
            },
            { command: { text: "Delete", click: removeNote }, title: " ", width: "180px" }],
            editable: true    

          }).data("kendoGrid");

    function removeNote() {
            var grid = $("#grid").data("kendoGrid");
            var sel = grid.select();     // Error here: TypeError: Cannot read property 'value' of undefined
            var item = grid.dataItem(sel);

            // other code goes here

      };

   function addNote() {
        var grid = $("#grid").data("kendoGrid");
        var item = grid.dataItem( grid.select());  // Error here: TypeError: Cannot read property 'value' of undefined

      //more code below 

}

TIA

 

1 Answer, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 12 Feb 2016, 12:15 PM

Hello Steve,

The reason for the issue is that the current Grid is not configured as selectable. The select() method is only applicable in a selectable Grid.

Regards,
Dimiter Madjarov
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
Steve
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Share this question
or