如何编辑flex dataProvider中的项目并支持取消?

时间:2022-11-03 05:25:35

I have a DataGrid of objects, and I want to modally edit them; pop up a dialog, change the item, and if the user clicks "Ok", save the changes back to the original item, and if they click "Cancel", do nothing. It seems obvious that if I simply pass in a reference to the original object and change it using data bindings to the fields in the edit form, I won't be able to cancel my edits. How can I support that capability?

我有一个DataGrid对象,我想对它们进行模态编辑;弹出一个对话框,更改项目,如果用户单击“确定”,则将更改保存回原始项目,如果他们单击“取消”,则不执行任何操作。很明显,如果我只是传入对原始对象的引用并使用数据绑定将其更改为编辑表单中的字段,我将无法取消编辑。我该如何支持这种能力?

1 个解决方案

#1


I ended up implementing this by copying all of the fields from the value object into the edit components, rather than data binding them. Then, on save, I copy them back to the value object. It's a bit verbose, so I'd love to find out that there's a better way.

我最终通过将值对象中的所有字段复制到编辑组件来实现它,而不是将它们绑定到数据。然后,在保存时,我将它们复制回值对象。它有点冗长,所以我很想知道有更好的方法。

#1


I ended up implementing this by copying all of the fields from the value object into the edit components, rather than data binding them. Then, on save, I copy them back to the value object. It's a bit verbose, so I'd love to find out that there's a better way.

我最终通过将值对象中的所有字段复制到编辑组件来实现它,而不是将它们绑定到数据。然后,在保存时,我将它们复制回值对象。它有点冗长,所以我很想知道有更好的方法。