validation in flex datagrid using itemEditor -
i have datagrid conatains 2 columns. datatype , value. datatype has combobox options char, int, unsigned int, signed int etc.now want have validation on value entered in value column. 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 int values. if char selected , need use different itemeditor validate in different way. in short,
if (int) use itemeditor1 else if (char) use itemeditor2 else if (condition) use itemeditor3.
can point me in correct direction?
the data
property (and datachange
event) make life easier.
for example,
(assuming datatype field type
)
in mxml:
<mx:itemeditor> <fx:component> <local:valueinput type="{data.type}"/> </fx:component> </mx:itemeditor>
valueinput.as:
package { import mx.controls.textinput; public class valueinput extends textinput { public function set type(value:string):void { switch (value) { case "char": restrict = null; break; case "int": restrict = "0-9"; break; case "hex": restrict = "0-9a-f"; break; } } } }
however, can't "correct direction". 1 way of doing it. there can many other creative ways, , depends on developer's coding style.
what trying fine way. takes bit longer implement mx components.
hope helps.
Comments
Post a Comment