How to implement simple two-way data binding?

Posted by: gerald on 17 August 2020, 3:30 am EST

    • Post Options:
    • Link

    Posted 17 August 2020, 3:30 am EST

    Hello!

    I created a simple example in Angular and bound data to an object.

    If I update the object’s data through a button click the sheet’s cells are not updated accordingly. I thought it is two-way data binding and it should work, right?

    Do I miss something?

    Archive.zip

  • Posted 18 August 2020, 6:40 am EST

    Hi Gerald,

    Thanks for the working Sample . For updating the changes on the sheet you need to refresh the spread sheet for this you may use refresh method. Please refer to the following code snippet.

     changeTestData() {
        this.dataSource.items[0].itemName = "hugo";
        this.spread.refresh();
      }
    

    We have also updated the sample. Please have look and let us know if you face any issues

    API References

    refresh: https://www.grapecity.com/spreadjs/docs/v13/online/SpreadJS~GC.Spread.Sheets.Workbook~refresh.html?highlight=refresh%2C

    Regards

    twoWayBinding.zip

  • Posted 18 August 2020, 7:56 am EST

    Thank you!

    What is the better approach:

    this.spread.refresh();

    or

    worksheet.repaint();

    ?

    Yesterday, I tried with repaint() and it works fine.

    What’s faster/better?

    best regards,

    Gerald

  • Posted 19 August 2020, 9:42 am EST

    Hi Gerald,

    Sheet.repaint() is faster than spread.refresh because its functionality is limited to the sheet where the refresh method refreshes the layout of the whole control in your case you may use repaint method since there is no need to refresh the whole control.

    Regards

  • Posted 19 August 2020, 9:52 am EST

    Hello!

    Thank you!

    Best regards,

    Gerald

Need extra support?

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

Learn More

Forum Channels