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

Edit click throws 'undefined' is not an object (evaluating 'this._set.get')

1 Answer 307 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Volker
Top achievements
Rank 1
Volker asked on 06 Feb 2012, 02:01 PM
Hi,

I could not find examples for all scenarios, here's where I'm at in the moment:
- read (mysql local database via php) works fine and as expected
- edit/save/delete throws errors

$("#grid").kendoGrid({
    dataSource: {
        transport: {
            read    : { url: "data/product_list.php"   , dataType : "json" } ,
            create  : { url: "data/product_create.php" , type: "POST" } ,
            update  : { url: "data/product_update.php" , type:"POST" } ,
            destroy : { url: "data/product_delete.php" , type: "POST" }
        },
        schema: {
            data: "data"
        } ,
        model: {
            id:"ID" ,
            fields : {
                ID : {
                    editable : false,
                    nullable : true } ,
                product_name : {
                    editable : false ,
                    nullable: true } ,
                name : { required : true } ,
                size : { required : true } ,
                weight : { required : true } ,
                glossy : { required : true } ,
                color : { required : true }
            }
        }
    },
    columns: [{ field: "ID" , title : "id" , width: "2em" } ,
              { field: "product_name" , title : "Product" } ,
              { field: "name" ,   title: "Name" } ,
              { field: "size" ,   title: "Size" } ,
              { field: "weight" , title: "Weight" } ,
              { field: "glossy" , title: "Shining" } ,
              { field: "color" ,  title: "Color" } ,
              { title: "" , command: "destroy" , width: "110px" }
                 ] ,
    toolbar : [ { name: "create" , text : "Add New Product" } , "save" , "cancel" ],
    detailTemplate: kendo.template($("#template").html()),
    detailInit: detailInit,
    sortable : {
        mode : "multiple" ,
        allowUnsort : true } ,
    editable : {
        update : true , destroy : true , confirmation: "really delete it? \n (press 'Save Changes' to delete it from server!)" }
});

Software info
  • Browser: Safari mac os x 5.1.2, Firefox 9.0.1 mac os x 
  • Kendo UI v2011.3.1129
Symptoms
  • grid is displayed correctly, all buttons show up (remove, toolbar)
  • when a) clicking inside a field to edit, b) after saying ok to the confirmation and c) when clicking on the save button, the following error is thrown
  • Safari: TypeError: 'undefined' is not an object (evaluating 'this._set.get') on line 4735
    Firefox: this._set is undefined on line 4735
  • line 4735 is in the uncompressed kendo.all.js (line number is for the a) event, might differ for other events)
  • detailInfo datagrid (not shown in code) is read and displayed correctly. Same erroneous behavior...
Database info
The database/php script is built on the kendo examples, SQL is this:
SELECT `ID` , CONCAT( name, ' ' , size , ' ' , pages , ' ' , weight  , ' ' , glossy , ' ' , color ) AS `product_name` , name , size , pages , weight , glossy , color FROM fp_products;");

  • "product_name" is a server-side-calculated field.
  • all fields are varchars, only ID is integer (no big amounts:)

Questions
  • is there a more complete example for all CRUD grid actions using the LAMP technology (or any other SQL based) stack?
  • any hints/tips about where I am heading in the wrong direction are greatly appreciated!
Many thanx in advance!
Volker

1 Answer, 1 is accepted

Sort by
0
Volker
Top achievements
Rank 1
answered on 07 Feb 2012, 08:02 AM
Found it! My model property was in the wrong place (same level as schema, but it has to be a child of the schema property). 
Here's the corrected dataSource code:
dataSource: {
            transport: {
                read    : { url: "data/product_list.php"   , dataType : "json" } ,
                create  : { url: "data/product_create.php" , type: "POST" } ,
                update  : { url: "data/product_update.php" , type:"POST" } ,
                destroy : { url: "data/product_delete.php" , type: "POST" }
            },
            schema: {
                data: "data" ,
                model: {
                    id:"ID" ,
                    fields : {
                        ID : {
                            editable : false,
                            nullable : true } ,
                        product_name : {
                            editable : false ,
                            nullable: true } ,
                        name : { validation: { required : true } } ,
                        size : { validation: { required : true } } ,
                        weight : { validation: { required : true } } ,
                        glossy : { validation: { required : true } } ,
                        color : { validation: { required : true } }
                    }
                }
            }
        }

Moving the "model" part into the schema solved my problem.
Tags
Grid
Asked by
Volker
Top achievements
Rank 1
Answers by
Volker
Top achievements
Rank 1
Share this question
or