开发者

Setting 'property' on validator

I'm using a NumberValidator on each cell in a column on a datagrid. The source is set to the datagrid's dataProvider but the property is the problem. I can't just say 'text' because I use a labelFunction to retrieve the property because it's nested inside another object.

Any way to get around this? Am I going to need to create my own custom validator? I hope not. Any tips are appreciated.

Thanks!

<mx:NumberValidator  
 source="{this.secId_dg.dataProvider}" lowerThanMinError="A locate is required."
 property="marketRule.locRule.locRuleId" minValue="0" />

 <mx:DataGrid
    editable="true"
    width="100%"
    rowCount="10"
    tabEnabled="false">
    
    <mx:columns>
        
        <mx:DataGridColumn
            editorDataField="text"
            editable="true">
            <mx:itemEditor>
                <mx:Component>
    
                </mx:Component>
            </mx:itemEditor>
        </mx:DataGridColumn>
        
        <mx:DataGridColumn
            headerText="Description"
            dataField="description"
            width="200"
            editable="false"/>
        <mx:开发者_JAVA百科DataGridColumn
            headerText="Locate"
            headerStyleName="leftGridHeader"
            paddingRight="4"
            textAlign="right"
            labelFunction="getLocate"
            editable="true"
            dataField="locRuleDesc"
            editorDataField="selectedLabel"
            />
        <mx:DataGridColumn
            headerText="Comments"
            width="200"
            editable="true"/>
        <mx:DataGridColumn
            headerText="Delete"
            editable="false"
            DeleteIconRenderer"/>
    </mx:columns>
</mx:DataGrid>


The solution here is to use the proper combination of source and property values. You were on the right track.

For the source property the documentation says this:

This property supports dot-delimited Strings for specifying nested properties.

So in your case, you would have wanted to make your source property string a bit longer, something that reached down into the item that contained the property to validate. Perhaps:

source="this.secId_dg.selectedItem.marketRule.locRule"

Then your property to validate would simply be:

property="locRuleId"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜