Our blazing fast Grid component built with pure JavaScript


Post by henrikbackman »

Hi,

For this error I've used your Car data file.

I have the columns Make, Model, Year, Repair freq and Color.
If the first row/object is missing color:
{"id":1,"make":"Spyker","model":"C8 Spyder","year":2004,"repairs":"Often"}
and the following look like this:
{"id":2,"make":"Chevrolet","model":"Express 2500","year":2004,"color":"Mauv","repairs":"Seldom"}
the color value for the rest of them won't be rendered.

What should I do to fix this?

Here is the complete code:
new bryntum.grid.Grid({
  appendTo: 'container',
  columns: [{
    text: 'Make',
    field: 'make',
  }, {
    text: 'Model',
    field: 'model',
  }, {
    text: 'Year',
    field: 'year',
  }, {
    text: 'Repair frequency',
    field: 'repairs',
  }, {
    text: 'Color',
    field: 'color',
  }],
  data: [{"id":1,"make":"Spyker","model":"C8 Spyder","year":2004,"repairs":"Often"}, // no "color": "red" here!
  {"id":2,"make":"Chevrolet","model":"Express 2500","year":2004,"color":"Mauv","repairs":"Seldom"},
  {"id":3,"make":"Jaguar","model":"X-Type","year":2002,"color":"Fuscia","repairs":"Daily"},
  {"id":4,"make":"Ford","model":"Crown Victoria","year":1994,"color":"Blue","repairs":"Never"},
  {"id":5,"make":"Ford","model":"E-Series","year":1986,"color":"Violet","repairs":"Seldom"},
  {"id":6,"make":"Mitsubishi","model":"Galant","year":1989,"color":"Goldenrod","repairs":"Weekly"},
  {"id":7,"make":"Lincoln","model":"LS","year":2001,"color":"Maroon","repairs":"Weekly"},
  {"id":8,"make":"GMC","model":"Canyon","year":2012,"color":"Puce","repairs":"Once"},
  {"id":9,"make":"Volvo","model":"S70","year":1998,"color":"Fuscia","repairs":"Daily"},
  {"id":10,"make":"Chevrolet","model":"Silverado 3500","year":2008,"color":"Teal","repairs":"Monthly"}]
});

Post by mats »

You should define this field in your data Model. We try to help as much as possible and detect fields from first record in a dataset, but the clean way is to describe your data Model properly with fields.

https://bryntum.com/docs/grid/#Common/data/Model

Post by henrikbackman »

What if we have have different fields for different pages using the same way to initialize the grid? Are you recommending that we define every single field we have?

Post by mats »

That would be the clean way yes, for the Grid Store / Model to map correctly to your data model.

Post Reply