Our blazing fast Grid component built with pure JavaScript


Post by Exigo »

Hello,

I have an issue when trying to extend the grid base model to add extra fields for a specfic use in my application. I want this field to be able to contain data very similar to your identifier fields with string | number.
However this does not seem possible from your documentation? Even if you have these fields yourselves.
If I have the type as number the strings are never saved to the model and stay as null values, and if I have the type as string it gives me an error whenever the model receives a number...

export class ExtendedModel extends Model {
  extraField: string | number;

  constructor(config?: Partial<ExtendedModel>) {
    super(config);
  }

  static get fields() {
    return [
      {
        name: 'extraField',
        type: 'number',
        alwaysWrite: true,
        persist: true
      }
    ];
  }
}

Is there anyway I can achieve this result??

Cheers
Andreas @ Exigo


Post by alex.l »

Hi Andreas,

Try to not provide any type for that field

  static get fields() {
    return [
      {
        name: 'extraField',
        alwaysWrite: true,
        persist: true
      }
    ];

All the best,
Alex


Post Reply