0
votes

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: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>
1
Sorry, not getting the code editor work correctly when adding comments. Anyway, above is the validator I'm trying to use. Obviously, the 'property' value is incorrect but I'm just trying to illustrate that what I want to validate is 'locRuleId' and that is part of the locRule object which is part of the marketRule object. - fumeng
erm, edit your original post maybe? And add more code than just the number validator. I want to see how you setup your datagrid. - J_A_X
If I were posting that question/trying to solve that problem, I would build a small test app (would rule out any other causes, and if you post a small app code, people will run it and try it themselves) - Drenai

1 Answers

0
votes

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"