如何使 Flex 列表组件中的项目编辑器提交其更改?
我有一个列表组件,并且有一个用于列表中项目的项目编辑器。 我希望有一个按钮,用户完成更改后可以单击该按钮,因为我让他们在编辑器中编辑多条数据,并且我还想在关闭编辑器之前验证数据。 我只是不知道如何处理按钮的单击事件以使项目编辑器关闭并将其更改提交给数据提供程序。
I have a list component and I have an item editor for the items in the list. I would like to have a button that the user clicks once they are done with their changes because I am having them edit multiple pieces of data in the editor and I would also like to validate the data before closing the editor as well. I just don't know what to do on the button's click event to make the item editor close and commit it's changes to the data provider.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要使用验证器来验证数据,我想也许可以对 updateComplete 和更改事件执行一些操作来延迟列表组件的更新:
http://livedocs.adobe.com/flex/201/html/ wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Book_Parts&file=celleditor_073_17.html
You'll want to use a validator to validate the data, and I think maybe do something with the updateComplete and change events to delay the updating of the list component:
http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Book_Parts&file=celleditor_073_17.html
我会使用数据绑定并让 Flex 为您完成工作。
拥有一个带有可绑定属性 myList:IList 的对象 myObject。 将显示绑定到该对象。
当您开始编辑时,复制该列表。
在 MouseEvent.CLICK 上:
I would use data binding and let Flex do the work for you.
Have an object myObject with a bindable property myList:IList. Bind the display to this object.
When you start editing, copy that list.
On MouseEvent.CLICK:
要处理列表控件中多个字段的编辑,您需要捕获 ItemEditEnd 事件,然后手动更改您感兴趣的字段。
请参阅此处的“示例:使用带有列表控件的自定义项目编辑器” - http://livedocs.adobe.com/flex/ 3/html/help.html?content=celleditor_9.html#226555。
通常,当您将焦点移出单元格时,列表将为您处理此事件的调度。 我不确定它的属性,但您应该能够在按钮单击处理程序中构造此事件,然后自己分派它。
To handle the editing of multiple fields in a List control, you will need to catch the ItemEditEnd event and then manually change the fields you are interested in.
See "Example: Using a custom item editor with a List control" in here - http://livedocs.adobe.com/flex/3/html/help.html?content=celleditor_9.html#226555.
Usually the List will handle the dispatching of this event for you when you focus out of a cell. I'm not sure of its properties off the top of my head, but you should be able to construct this event in your button click handler, and then just dispatch it yourself.