Cannot read property 'value' of undefined

2 posts, 0 answers
  1. Steve
    Steve avatar
    41 posts
    Member since:
    Apr 2015

    Posted 10 Feb 2016 Link to this post

    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

     

  2. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2312 posts

    Posted 12 Feb 2016 Link to this post

    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!
     
Back to Top