如何使 Flex 列表组件中的项目编辑器提交其更改?

发布于 2024-07-20 13:48:51 字数 140 浏览 8 评论 0原文

我有一个列表组件,并且有一个用于列表中项目的项目编辑器。 我希望有一个按钮,用户完成更改后可以单击该按钮,因为我让他们在编辑器中编辑多条数据,并且我还想在关闭编辑器之前验证数据。 我只是不知道如何处理按钮的单击事件以使项目编辑器关闭并将其更改提交给数据提供程序。

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

蓝咒 2024-07-27 13:48:51

您需要使用验证器来验证数据,我想也许可以对 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

老街孤人 2024-07-27 13:48:51

我会使用数据绑定并让 Flex 为您完成工作。

拥有一个带有可绑定属性 myList:IList 的对象 myObject。 将显示绑定到该对象。

当您开始编辑时,复制该列表。

在 MouseEvent.CLICK 上:

var ed:Editor // Your list editing object.
var edProvider:IList = ed.dataProvider;
var targList:IList   = myObject.myList; 

var bool:Boolean     = ( myObject.myList.length > edProvider.length );
var len:int          = ( bool )? targList.length: edProvider.length; 

var item:*           = null;

for( var i:int = 0; i < len; i++ )
{
    try // a "just in case".  You probably will never have a problem.
    {
        item = edProvider.getItemAt( i );
        targList.setItemAt( item, i );
    }
    catch( error:Error )
    {
        continue;
    }
}

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:

var ed:Editor // Your list editing object.
var edProvider:IList = ed.dataProvider;
var targList:IList   = myObject.myList; 

var bool:Boolean     = ( myObject.myList.length > edProvider.length );
var len:int          = ( bool )? targList.length: edProvider.length; 

var item:*           = null;

for( var i:int = 0; i < len; i++ )
{
    try // a "just in case".  You probably will never have a problem.
    {
        item = edProvider.getItemAt( i );
        targList.setItemAt( item, i );
    }
    catch( error:Error )
    {
        continue;
    }
}
烟若柳尘 2024-07-27 13:48:51

要处理列表控件中多个字段的编辑,您需要捕获 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文