Our blazing fast Grid component built with pure JavaScript


Post by henrique »

I'm starting a test here, but it's a very strange error.

This source below is giving error "Cannot create property 'id' on number '7'" .

Can anyone tell me what I did wrong?

import Model from '../../lib/Core/data/Model.js';
import Store from '../../lib/Core/data/Store.js';

let myData = new Store({
        fields : [
            'type'
        ], 
        data : [
            { id : 1, name : 'pizza', type : 'food' },
            { id : 2, name : 'bacon', type : 'food' },
            { id : 3, name : 'egg', type : 'food' },
            { id : 4, name : 'Gin tonic', type : 'drinks' },
            { id : 5, name : 'Wine', type : 'drinks' },
            { id : 6, name : 'Beer', type : 'drinks' }
        ]
    });

class MyModel extends Model {
   static get fields() {
      return [
         { name: "id", type: "string" },
         { name: "food", type: "model" }
      ];
   }
}

let myValue = new MyModel(
//{id: 25, Food: myData.records[3]}
);

let myData2 = new Store({data: myValue});

Post by alex.l »

Hi henrique,

data should be an array, not a Model

let myData2 = new Store({data : [myValue] });

https://bryntum.com/docs/grid/api/Core/data/Store#config-data

All the best,
Alex


Post by henrique »

Thanks! Tip, give an error if the parameter is not an array!


Post Reply