bryntum / support

An issues-only repository for the Bryntum project management component suite which includes powerful Grid, Scheduler, Calendar, Kanban Task Board and Gantt chart components all built in pure JS / CSS / TypeScript
https://www.bryntum.com
53 stars 6 forks source link

useRawData default to true makes create new record not work correctly #9701

Closed marciogurka closed 1 month ago

marciogurka commented 2 months ago

Forum post

"useRawData default to true causing a bug. The bug is if I have a defaultValue set for fields in my model class and then I try to create a record with data, the default values in model class replaces my provided data with the defaults.

import { Model, Store, ProjectModel } from '../../build/schedulerpro.module.js?478335';
import shared from '../_shared/shared.module.js?478335';

class MyModel extends Model {
  static get fields() {
    return [
      { name: "myName", dataSource: "name", defaultValue: "novalue" },
      { name: "isDefaultView", dataSource: "is_default_view", type: "boolean", defaultValue: false },
    ]
  }
}

const testStore = new Store({
  storeId: "testStore",
  modelClass: MyModel,
  // useRawData: false
});

const testProject = new ProjectModel({
  crudStores: [
    testStore
  ],
  loadUrl: "https://www.test.com",
})
console.log(testProject)
testProject.useRawData = false;

const viewToAdd = testStore.createRecord({
    myName: "test",
    isDefaultView: true,
});
console.log(viewToAdd.myName, viewToAdd.isDefaultView); // logs: novalue, false

As you can see from the output my provided values are ignored but If I sets the useRawData in store to false it works fine."

Live CodePen - https://codepen.io/marciogurka/pen/xxogjPW

isglass commented 1 month ago

Duplicate of https://github.com/bryntum/support/issues/9712