Posted 29 January 2019, 4:10 pm EST
Hi Raznin,
If we understand correctly, then you have getter/setter props defined on the item now when you extend the object you are expecting the getter/setter to be copied on the row.dataItem object as well.
The issue with the approach is that getter/setter are not copied to the new object automatically, we need to define them on row.dataItem explicitly.
Please refer to the following code snippet:
let descriptor = Object.getOwnPropertyDescriptor(Item.prototype, "propName");
Object.defineProperty(row.dataItem, "propName", descriptor);
A better and recommended solution in this case would be to just simply assign a newItemCreator function on the source collectionView which return an object of the appropriate type for the row.dataItem.
Please refer to the following code snippet and sample:
let source = new wjcCore.CollectionView(getData(50));
source.newItemCreator = () => {
return new Item(-1, "default country");
};
flexSheet.addBoundSheet("sheet", source);
https://codesandbox.io/s/k3yx6w23lr
Also,just wanted to confirm if this is the recommended way of inserting a row.
<<<<<<<<<<<<<<
Yes indeed, insertRows() method is the recommended way of inserting new rows. As for the default values assigning a newItemCreator function is the recommended approach.
~Sharad