Change of collectionview lost when trying to save

Posted by: moritz.neugebauer on 28 July 2020, 5:32 pm EST

  • Posted 28 July 2020, 5:32 pm EST

    Dear Wijmo Team,

    I'm struggling to send data to a server. When editing an item, the change in the collectionview is corretly stored. But when calling a save function, the change in the collectionview is lost.

    Change method called by button click
    * parameter item is an item from the collectionview
    * gridData is the collectionView that is created as a component property
    like so: public gridData: wjcCore.CollectionView = new wjcCore.CollectionView();

    change(item) {
    this.gridData.editItem(item.date);
    item.date = this.date;
    this.gridData.commitEdit();
    item.dirty = true;
    this.gridData.refresh();

    console.log("gridData: ", this.gridData); //here everything is fine
    }


    Async function to send data to server

    async save() {
    //here the change is already lost, even the dirty flag is gone
    console.log("gridData: ", this.gridData);

    for (let i = 0; i < this.gridData.items.length; i++) {
    let tmpItem = this.gridData.items[i];

    // even though the dirty flag is gone the code successfully passes the if statement
    if (tmpItem.dirty === true && tmpItem['id']) {
    console.log("tmpItem: ", tmpItem); // the single item that was changed, but the change is lost
    let convertedItem = Utils.convertFromNative2Katalogwert(tmpItem, this.katalogAttributeMap);
    updatedItems.push(convertedItem);
    }
    }


    This is kind of strange. It seems like there is a second instance of gridData flying around but I have no idea why.

    Do you have an idea why this might happen?

    Best regards
    Moritz
  • Marked as Answer

    Replied 28 July 2020, 5:47 pm EST

    Dear Wijmo Team,

    feel free to close/delete my post. Everything works as expected! My bad.

    Best regards
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels