I have a datagrid which conatains two columns. Datatype and value. Datatype has a combobox with options like char, int, unsigned int, signed int etc.Now i want to have validation on what value is entered in value column. I am using following method .
<mx:DataGridColumn headerText="Value"
dataField="Values"
width="100"
editable="{!this.areVariablesReadOnly}">
<mx:itemEditor> <mx:Component> <mx:TextInput restrict="0-9" maxChars="3" /> </mx:Component> </mx:itemEditor>
</mx:DataGridColumn>
This validates value column's fields only for int values. Now if char is selected , i need to use different itemEditor to validate in a different way. In short,
if (int)
use ItemEditor1
else if (char)
use ItemEditor2
else if (condition)
use Itemeditor3.
Can anybody point me in correct direction?
The
dataproperty (and alsodataChangeevent) will make your life easier.For example,
(assuming that your Datatype field is
type)In your MXML:
ValueInput.as:
However, I can't say this is the "correct direction". It is just one way of doing it. There can be many other creative ways, and it also depends on developer's coding style.
What you were trying to do was also a fine way. It just takes a bit longer to implement for MX components.
Hope this helps.