0

DataGridから拡張するCustomDataGridとDataGridColumnから拡張するCustomDataGridColumnがあります。

CustomDataGridColumnには、Function型のメンバー変数があります。

ビュー内に、パセリを使用してプレゼンテーションモデルを挿入します。

コードは次のとおりです。

<fx:Declarations> 
        <spicefactory:Configure/> 
    </fx:Declarations> 

<fx:Script> 

        [Inject(id="associatedDocumentsPM")] 
        [Bindable] 
        public var model:AssociatedDocumentsPM; 


</fx:Script> 

   <customDataGrid:CustomDataGrid id="AssocDocGrid" 
                                   width="100%" height="{(documentDataList.length+2)*20}" 
                                   doubleClickEnabled="true" enabled="{modeHandler.appEnable}" 
                                   dataP="{documentDataList}" 
                                   sortableColumns="false"> 
        <customDataGrid:columnList> 
            <customDataGrid:CustomDataGridColumn 
                textAlign="left" 
                dataFieldIdentifier="documentName" 
                headerText="Document Type" 
                modifyLabelField="{model.modifyLabelField}" 
                dataField="documentName" 
                isNaNZero="true" 
                showDataTips="true" 
                editable="false"/> 
                ...more columns here...  
       </customDataGrid:columnList>
    </customDataGrid:CustomDataGrid>

AssociatedDocumentsPMには関数が定義されており、これらは列に設定されています。

属性の例modifyLabelField="{model.modifyLabelField}"

CustomDataGridColumn.myLabelFieldのタイプはFunctionです。AssociatedDocumentsPM内のmyLabelFieldはパブリック関数です。

Parsley Contextファイルは上記のファイルの親にあり、PMを次のように宣言します。

AssocDocPMFactoryは、[Factory]で装飾された唯一の関数を持つクラスです。

したがって、問題は次のとおりです。

アプリケーションをデバッグしてDataGridのcolumnListを確認すると、変数modifyLabelFieldがnullになります。

関数バインディングは変数とは異なる方法で処理されますか?Flex4.5.1をParsley2.4.1と一緒に使用しています

CreationCompleteが呼び出された後にインジェクションが発生する可能性があることは理解していますが、バインディングがそれを処理すると思いました。

モデル(PM)はずっと後になるまでヌルであり、関数のバインドはトリガーされないように感じます。

FastInjectも使用しようとしましたが、役に立ちませんでした。

これは関数ポインタとFlexバインディングの問題ですか?

4

1 に答える 1

0

いいえ、そうではありません。このような疑問がある場合は、仮定を検証する単純な分離テスト状況をすばやく設定することをお勧めします。私はあなたをテストするために以下を作成しました:

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               creationComplete="onCreationComplete()" >

    <fx:Script>
        <![CDATA[
            private function onCreationComplete():void {
                test = function(item:*):String {
                    return "AAA";
                }
            }

            [Bindable]
            private var test:Function;
        ]]>
    </fx:Script>

    <s:List labelFunction="{test}">
        <s:dataProvider>
            <s:ArrayList>
                <fx:String>A</fx:String>
                <fx:String>B</fx:String>
                <fx:String>C</fx:String>
            </s:ArrayList>
        </s:dataProvider>
    </s:List>

</s:Application>

testFunction変数が宣言されている場合、Bindable「AAA」が3回表示されます。メタデータを削除すると、Bindable「A」、「B」、「C」が表示されます。

したがって、明らかにバインディングは関数ポインタでも機能します(そして、nullpointerを見つけるために他の場所を探す必要があります)。

于 2012-05-16T09:09:55.660 に答える