Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache flex flex itemrenderer阻止datagrid项选择_Apache Flex_Datagrid_Adobe_Mxml_Itemrenderer - Fatal编程技术网

Apache flex flex itemrenderer阻止datagrid项选择

Apache flex flex itemrenderer阻止datagrid项选择,apache-flex,datagrid,adobe,mxml,itemrenderer,Apache Flex,Datagrid,Adobe,Mxml,Itemrenderer,我对Flex有点陌生,在itemRenderer中遇到了一个我找不到解决方案的问题。我问过一位有丰富flex经验的同事,我尝试过在互联网上搜索,但运气不佳。 我的问题是,我有一个dataGrid,其中每列都使用itemRenderer来显示信息,由于某种原因,这会导致用户无法选择任何dataGrid行。我认为这一定与itemRenderer有关,因为当我添加了一个没有itemRenderer的虚拟列时,我可以通过单击该虚拟列高亮显示并选择一行,但其他列仍然不起作用。我曾尝试将我的代码与其他数据网

我对Flex有点陌生,在itemRenderer中遇到了一个我找不到解决方案的问题。我问过一位有丰富flex经验的同事,我尝试过在互联网上搜索,但运气不佳。 我的问题是,我有一个dataGrid,其中每列都使用itemRenderer来显示信息,由于某种原因,这会导致用户无法选择任何dataGrid行。我认为这一定与itemRenderer有关,因为当我添加了一个没有itemRenderer的虚拟列时,我可以通过单击该虚拟列高亮显示并选择一行,但其他列仍然不起作用。我曾尝试将我的代码与其他数据网格的代码与ItemRenderer进行比较,但我没有发现任何可能导致我遇到的问题的差异。有人知道为什么会这样吗? 谢谢大家!

我的数据网格我试图只包含我认为应该相关的内容,只是为了保持简洁。如果有人认为需要更多信息,请告诉我!:

<mx:DataGrid id="servicegridUI" left="10" right="10" top="10" bottom="85" selectable="true" 
                 styleName="formDataGrid" variableRowHeight="true" toolTip="Double-click to view.">
        <mx:columns>
            <mx:DataGridColumn headerText="ID" dataField="ID" width="175">
                <mx:itemRenderer>
                    <mx:Component>
                        <mx:HBox paddingBottom="3" height="70" paddingLeft="5" horizontalGap="1" paddingTop="2" horizontalScrollPolicy="off" verticalScrollPolicy="off">
                            <mx:Text height="100%" width="100%" id="id" htmlText="" selectable="true" doubleClick="openDoc(event)" doubleClickEnabled="true"/>
                            <mx:Script>
                                <![CDATA[                           
                                    var refId:String = "";
                                    override public function set data(value:Object):void {
                                        //variables for setting text are created here
                                        id.htmlText = 'ID: ' + refId + '<br><font color="#666666">Service ID: ' + servId + '</font>';
                                        id.htmlText +='<br><font color="#666666">Type and Specialty: ' + type + ' - ' + specialty + '</font>';
                                    }

                                    public function openDoc(event:MouseEvent):void {            
                                       //removed due to irrelevance
                                    }
                                ]]>
                            </mx:Script>
                        </mx:HBox>
                    </mx:Component>
                </mx:itemRenderer>
            </mx:DataGridColumn>
            <mx:DataGridColumn headerText="Claimant" dataField="claimantHeader" width="125">
                <mx:itemRenderer>
                    <mx:Component>
                        <mx:HBox paddingBottom="3" height="70" paddingLeft="5" horizontalGap="1" paddingTop="2" horizontalScrollPolicy="off" verticalScrollPolicy="off">
                            <mx:Text height="100%" width="100%" id="claimant" htmlText="" selectable="true" doubleClick="openDoc(event)" doubleClickEnabled="true"/>
                            <mx:Script>
                                <![CDATA[   
                                    var refId:String = "";
                                    override public function set data(value:Object):void {
                                        //variables for setting text are created here
                                        claimant.htmlText = 'Claim: ' + claim + '<br><font color="#666666">Name: '+ name +'</font>';
                                        claimant.htmlText +='<br><font color="#666666">Date: '+ date+'</font>';
                                        }

                                    // Opens a new browser window and loads the file
                                    public function openDoc(event:MouseEvent):void {            
                                        //removed due to irrelevance
                                    }
                                ]]>
                            </mx:Script>
                        </mx:HBox>
                    </mx:Component>
                </mx:itemRenderer>
            </mx:DataGridColumn>
            <mx:DataGridColumn headerText="Status" dataField="statusHeader" width="70">
                <mx:itemRenderer>
                    <mx:Component>
                        <mx:HBox paddingBottom="3" height="70" paddingLeft="5" horizontalGap="1" paddingTop="2" horizontalScrollPolicy="off" verticalScrollPolicy="off" >
                            <mx:Text height="100%" width="100%" id="status" htmlText="" selectable="true" doubleClick="openDoc(event)" doubleClickEnabled="true"/>
                            <mx:Script>
                                <![CDATA[               
                                    var refId:String = "";
                                    override public function set data(value:Object):void {
                                        //variables for setting text are created here
                                        status.htmlText = 'Date: ' + refDate;
                                        status.htmlText += '<br><font color="#666666">Status: ' + currStatus + '</font>';
                                    }

                                    // Opens a new browser window and loads the file
                                    public function openDoc(event:MouseEvent):void {            
                                        //removed due to irrelevance
                                    }
                                ]]>
                            </mx:Script>
                        </mx:HBox>
                    </mx:Component>
                </mx:itemRenderer>
            </mx:DataGridColumn>
            <mx:DataGridColumn headerText="lalala" dataField="serviceID" width="50"/><!---this is the dummy column that I created and is the only one that functions properly-->
        </mx:columns>
    </mx:DataGrid>

当您重写set data函数时,您需要说

super.data = value;
它会解决你的问题。 如果要运行完整的应用程序,以下是基于代码的示例:

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script><![CDATA[
    import mx.collections.ArrayCollection;
    [Bindable]
    private var myArrayCollection:ArrayCollection = new ArrayCollection([
        {ID:"1",claimantHeader: "ClaimHeader1",statusHeader:"StatusHeader1", serviceID:"SID1" , servId:"1001", name:"Bikram Dangol", type:"Type 1",specialty:"Speciality 1", claim:"Claim 1", date:"12/06/2014", refDate:"11/06/2014", currStatus:"Active"},
        {ID:"2",claimantHeader: "ClaimHeader2",statusHeader:"StatusHeader2", serviceID:"SID2", servId:"1002", name:"Anup Dangol", type:"Type 2",specialty:"Speciality 2", claim:"Claim 2", date:"12/07/2014", refDate:"11/07/2014", currStatus:"Inactive"},
        {ID:"3",claimantHeader: "ClaimHeader3",statusHeader:"StatusHeader3", serviceID:"SID3", servId:"1003",name:"Lunish Yakami", type:"Type 3",specialty:"Speciality 3", claim:"Claim 3", date:"12/08/2014", refDate:"11/08/2014", currStatus:"OnHold"},
                                                                            ]);
    ]]></mx:Script>
<mx:DataGrid id="servicegridUI" left="10" right="10" top="10" bottom="85" selectable="true" dataProvider="{myArrayCollection}"
             styleName="formDataGrid" variableRowHeight="true" toolTip="Double-click to view.">
    <mx:columns>
        <mx:DataGridColumn headerText="ID" dataField="ID" width="175">
            <mx:itemRenderer>
                <mx:Component>
                    <mx:HBox paddingBottom="3" height="70" paddingLeft="5" horizontalGap="1" paddingTop="2" horizontalScrollPolicy="off" verticalScrollPolicy="off">
                        <mx:Text height="100%" width="100%" id="ID" htmlText="" selectable="true" doubleClick="openDoc(event)" doubleClickEnabled="true"/>
                        <mx:Script>
                            <![CDATA[
                            var refId:String = "";
                            override public function set data(value:Object):void {
                                super.data = value;
                                //variables for setting text are created here
                                ID.htmlText = 'ID: ' + refId + '<br><font color="#666666">Service ID: ' + data.servId + '</font>';
                                ID.htmlText +='<br><font color="#666666">Type and Specialty: ' + data.type + ' - ' + data.specialty + '</font>';
                            }

                            public function openDoc(event:MouseEvent):void {
                                //removed due to irrelevance
                            }
                            ]]>
                        </mx:Script>
                    </mx:HBox>
                </mx:Component>
            </mx:itemRenderer>
        </mx:DataGridColumn>
        <mx:DataGridColumn headerText="Claimant" dataField="claimantHeader" width="125">
            <mx:itemRenderer>
                <mx:Component>
                    <mx:HBox paddingBottom="3" height="70" paddingLeft="5" horizontalGap="1" paddingTop="2" horizontalScrollPolicy="off" verticalScrollPolicy="off">
                        <mx:Text height="100%" width="100%" id="claimant" htmlText="" selectable="true" doubleClick="openDoc(event)" doubleClickEnabled="true"/>
                        <mx:Script>
                            <![CDATA[
                            var refId:String = "";
                            override public function set data(value:Object):void {
                                super.data = value;
                                //variables for setting text are created here
                                claimant.htmlText = 'Claim: ' + data.claim + '<br><font color="#666666">Name: '+ data.name +'</font>';
                                claimant.htmlText +='<br><font color="#666666">Date: '+ data.date+'</font>';
                            }

                            // Opens a new browser window and loads the file
                            public function openDoc(event:MouseEvent):void {
                                //removed due to irrelevance
                            }
                            ]]>
                        </mx:Script>
                    </mx:HBox>
                </mx:Component>
            </mx:itemRenderer>
        </mx:DataGridColumn>
        <mx:DataGridColumn headerText="Status" dataField="statusHeader" width="70">
            <mx:itemRenderer>
                <mx:Component>
                    <mx:HBox paddingBottom="3" height="70" paddingLeft="5" horizontalGap="1" paddingTop="2" horizontalScrollPolicy="off" verticalScrollPolicy="off" >
                        <mx:Text height="100%" width="100%" id="status" htmlText="" selectable="true" doubleClick="openDoc(event)" doubleClickEnabled="true"/>
                        <mx:Script>
                            <![CDATA[
                            var refId:String = "";
                            override public function set data(value:Object):void {
                                super.data = value;
                                //variables for setting text are created here
                                status.htmlText = 'Date: ' + data.refDate;
                                status.htmlText += '<br><font color="#666666">Status: ' + data.currStatus + '</font>';
                            }

                            // Opens a new browser window and loads the file
                            public function openDoc(event:MouseEvent):void {
                                //removed due to irrelevance
                            }
                            ]]>
                        </mx:Script>
                    </mx:HBox>
                </mx:Component>
            </mx:itemRenderer>
        </mx:DataGridColumn>
        <mx:DataGridColumn headerText="lalala" dataField="serviceID" width="50"/><!---this is the dummy column that I created and is the only one that functions properly-->
    </mx:columns>
</mx:DataGrid>
</mx:Application>

似乎您没有在itemRenderer中实现某些状态。尝试从DataGridItemRenderer类扩展您的itemRenderer。这样做了-非常感谢!这无疑是一个宝贵的Flex经验教训。