设置“财产”的验证
问题描述:
我使用的每个小区的NumberValidator在一个DataGrid列。源设置为datagrid的dataProvider,但属性是问题。我不能只说'文本',因为我使用labelFunction来检索属性,因为它嵌套在另一个对象中。设置“财产”的验证
任何方式来解决这个问题?我是否需要创建自己的自定义验证器?我希望不是。任何提示都表示赞赏。
谢谢!
<mx:NumberValidator id="security_locate_numberValidator"
source="{this.secId_dg.dataProvider}" lowerThanMinError="A locate is required."
property="marketRule.locRule.locRuleId" minValue="0" />
<mx:DataGrid
id="secId_dg"
editable="true"
dataProvider="{this.marketRuleServiceEntity.exceptionComposites}"
itemEditEnd="onSecurityPicked(event)"
width="100%"
rowCount="10"
tabEnabled="false">
<mx:columns>
<mx:DataGridColumn
headerText="Security ID"
labelFunction="getSecId"
editorDataField="text"
editable="true">
<mx:itemEditor>
<mx:Component>
<application:SecuritySuggestInput
maxWidth="160"
minWidth="160"
toolTip="Search on a Ticker, CUSIP, or Sedol"
width="160"
prompt="Search Security"/>
</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"
itemEditor="com.fidelity.primeservices.act.editor.overrides.LocatesEditor"/>
<mx:DataGridColumn
headerText="Comments"
width="200"
editable="true"/>
<mx:DataGridColumn
headerText="Delete"
editable="false"
itemRenderer="com.fidelity.primeservices.act.renderer.overrides.SecuritiesDeleteIconRenderer"/>
</mx:columns>
</mx:DataGrid>
答
这里的解决方案是使用的source
和property
值的正确组合。你在正确的轨道上。
对于source
属性的文件这样说:
此属性支持点分隔的字符串指定嵌套属性。
你的情况
所以,你本来想使你的source
属性字符串的时间长一点,东西伸手到包含要验证的属性的项目。也许:
source="this.secId_dg.selectedItem.marketRule.locRule"
然后你的财产,以验证将仅仅是:
property="locRuleId"
请提供代码。 – 2011-03-28 18:45:59
对不起,添加注释时没有让代码编辑器正常工作。无论如何,上面是我尝试使用的验证器。显然,'属性'值是不正确的,但我只是想说明我想要验证的是'locRuleId',它是属于marketRule对象一部分的locRule对象的一部分。 – fumeng 2011-03-28 18:51:01
恩,编辑您原来的帖子也许?并且添加更多的代码而不仅仅是数字验证器。我想看看你如何设置你的数据网格。 – 2011-03-28 19:03:57