首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Flex selectedItem问题

Flex selectedItem问题
EN

Stack Overflow用户
提问于 2011-02-16 01:23:54
回答 1查看 2K关注 0票数 3

我在flex中遇到了一些奇怪的事情,可能是我做错了什么,但我不确定。

在我注意到的两种情况下,当s:List或s:DropDownList中只有一项时,使用list.selectedItem时,由于某种原因,它显示为null。使用requireSelection="true“我知道事实并非如此。

其他人有没有看到过类似的东西?还是我做得完全错了?谢谢乔恩

Edit:在下面的代码中,它发生在单击编辑文档时,这将调用open edit方法

-添加代码

我删除了一小部分以使其更具可读性

代码语言:javascript
复制
<s:TitleWindow width="486" height="300" title="Document Store"
               xmlns:tmsbean="services.tmsbean.*"
               close="close()">
    <fx:Declarations>
        <s:CallResponder id="getAllAttachedDocumentsResult"/>
        <tmsbean:TMSBean id="tMSBean" showBusyCursor="true"/>
        <s:CallResponder id="removeDocumentLinkResult" result="getDocumentList()"/>
    </fx:Declarations>
    <fx:Script>
        <![CDATA[


        private static var documentStoreView:DocumentStoreView = null;
        [Bindable]
        private var attachedToMenomic:String;

        public static function getInstance():DocumentStoreView
        {
            if(documentStoreView == null){
                documentStoreView = new DocumentStoreView();
                DocumentForm.getInstance().addEventListener(DocumentFormEvent.DOCUMENT_ATTACHED,documentStoreView.getDocumentList);
            }
            return documentStoreView;
        }

        public function open(menomic:String,parent:DisplayObject):void
        {
            attachedToMenomic = menomic;
            getDocumentList();
            PopUpManager.addPopUp(documentStoreView,parent,true);
            PopUpManager.centerPopUp(documentStoreView);
            y = y - 80;
        }

        public function close():void
        {
            PopUpManager.removePopUp(documentStoreView);
        }

        private function getDocumentList(evt:DocumentFormEvent = null):void
        {
            getAllAttachedDocumentsResult.token = tMSBean.getAllAttachedDocuments(attachedToMenomic);
        }


        private function openEdit():void{
            var editDsi:DocumentStoreItem = documentList.selectedItem as DocumentStoreItem;
            Alert.show(editDsi.documentName);
            DocumentForm.getInstance().openInEditMode(editDsi,this);
        }

    ]]>
</fx:Script>

<s:VGroup left="10" top="10" right="10" bottom="10">
    <s:List width="100%"  height="100%" id="documentList" itemRenderer="com.documentStore.DocumentItemListRenderer" 
            dataProvider="{Utilitys.toArrayCollection(getAllAttachedDocumentsResult.token.result)}" />
    <s:HGroup horizontalAlign="right" width="100%">
        <s:Button label="Attach Document" click="{DocumentForm.getInstance().open(attachedToMenomic,this)}"/>
        <s:Button label="Edit Document" click="openEdit()"/>
    </s:HGroup>
</s:VGroup> 
</s:TitleWindow>
EN

回答 1

Stack Overflow用户

发布于 2011-02-16 02:55:57

默认情况下,如果selectedIndex为-1,Spark的DropDownList将显示prompt,如果requireSelection为false,并且您没有将列表设置为特定项目,则会出现这种情况。这将对应于selectedItem为null。

Spark ComboBox做了类似的事情,但它有一个TextInput,你可以在里面输入。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5007076

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档