Andrew, I had created a custom DataGrid that overrode the setFocusedCell function. This allowed me to create my custom TextInput as the cell editor and add a listener on the cellFocusOut event. This listener populated the event object value and colName attributes. The purpose of using this approach was to have the flexibility to create a different cellEditor for each column. However, since this approach seems overly complex and does not seem to port well to Flex 2.0, I used the cell renderer approach that Doug and bod suggested. Thanks!
Gary --- In flexcoders@yahoogroups.com, "Andrew Trice" <[EMAIL PROTECTED]> wrote: > > Gary, > > I put your code into a sample application. For me, it returned a > validation error for any value that is put into the TextInput object. I > modified your code to get validation working, although it is still > ignoring the colName variable. I am not sure where that value is being > set or what it represents. How is this being used? Are you using it as > a custom implementation for a normal mx:TextInput object, or are you > using it as a custom cell renderer for a mx:DataGrid object? > > > > <?xml version="1.0" encoding="utf-8"?> > > <mx:TextInput xmlns:mx="http://www.macromedia.com/2003/mxml" > > > <mx:Script> > > <![CDATA[ > > > > function customValidate() { > > > > var validator = > arguments[0][0].validator; > > > > if ( this.text != "test" ) validator.validationError( null, "The value > does not equal 'test'.", null ); > > } > > ]]> > > </mx:Script> > > > > <mx:Model id="theModel"> > > <text>{text}</text> > > </mx:Model> > > > > <mx:Validator field="theModel.text" > validate="customValidate(arguments)" listener="this" /> > > > > </mx:TextInput> > > > > -Andy > > > > > > _____________________________________ > > Andrew Trice > > Cynergy Systems, Inc. > > http://www.cynergysystems.com > > > > Email: [EMAIL PROTECTED] > > Office: 866-CYNERGY > > > > ________________________________ > > From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On > Behalf Of Ault, Gary - BLS > Sent: Wednesday, April 12, 2006 2:30 PM > To: flexcoders@yahoogroups.com > Subject: [flexcoders] Custom dg validator > > > > In Flex 1.5, I am trying to create a PowerBuilder-esque column > validator. I use a custom TextInput field with a Validator so that when > a user tabs out of a column, the validation check is triggered. It > appears to work for a simple test, but I cannot get the validation error > to trigger for other conditions. Can anyone see a flaw or have another > approach to share? Thanks. Here is my custom TextInput with validator: > > <?xml version="1.0" encoding="utf-8"?> > <mx:TextInput xmlns:mx="http://www.macromedia.com/2003/mxml" > > <mx:Model id="theModel"> > <text>{text}</text> > </mx:Model> > > <mx:Validator field="theModel.text" validate="customValidate( event )" > listener="this" /> > > <mx:Script> > <![CDATA[ > > function customValidate(event ) { > var validator = event.validator; > var value = event.value; > var colName = event.colName; > //this works > //if ( value != "test" ) > //validator.validationError( null, "Value must > be an arithmetic operator", null ); > //this does not work > if (colName =="rptPricesOper" && value != "test") > validator.validationError( null, "Value > must be an arithmetic operator", null ); > > } // end customValidate > ]]> > </mx:Script> > > </mx:TextInput> > > > > Gary Ault > Bureau of Labor Statistics > > > > -- > Flexcoders Mailing List > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt > Search Archives: > http://www.mail-archive.com/flexcoders%40yahoogroups.com > > > > > SPONSORED LINKS > > Web site design development > <http://groups.yahoo.com/gads? t=ms&k=Web+site+design+development&w1=Web+ > site+design+development&w2=Computer+software+development&w3=Software+d es > ign+and+development&w4=Macromedia+flex&w5=Software+development+best+pr ac > tice&c=5&s=166&.sig=L-4QTvxB_quFDtMyhrQaHQ> > > Computer software development > <http://groups.yahoo.com/gads? t=ms&k=Computer+software+development&w1=We > b+site+design+development&w2=Computer+software+development&w3=Software +d > esign+and+development&w4=Macromedia+flex&w5=Software+development+best+ pr > actice&c=5&s=166&.sig=lvQjSRfQDfWudJSe1lLjHw> > > Software design and development > <http://groups.yahoo.com/gads? t=ms&k=Software+design+and+development&w1= > Web+site+design+development&w2=Computer+software+development&w3=Softwa re > +design+and+development&w4=Macromedia+flex&w5=Software+development+bes t+ > practice&c=5&s=166&.sig=1pMBCdo3DsJbuU9AEmO1oQ> > > Macromedia flex > <http://groups.yahoo.com/gads? t=ms&k=Macromedia+flex&w1=Web+site+design+ > development&w2=Computer+software+development&w3=Software+design+and+de ve > lopment&w4=Macromedia+flex&w5=Software+development+best+practice&c=5&s =1 > 66&.sig=OO6nPIrz7_EpZI36cYzBjw> > > Software development best practice > <http://groups.yahoo.com/gads? t=ms&k=Software+development+best+practice& > w1=Web+site+design+development&w2=Computer+software+development&w3=Sof tw > are+design+and+development&w4=Macromedia+flex&w5=Software+development+ be > st+practice&c=5&s=166&.sig=f89quyyulIDsnABLD6IXIw> > > > > > > ________________________________ > > YAHOO! GROUPS LINKS > > > > * Visit your group "flexcoders > <http://groups.yahoo.com/group/flexcoders> " on the web. > > * To unsubscribe from this group, send an email to: > [EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED]> > > * Your use of Yahoo! Groups is subject to the Yahoo! Terms of > Service <http://docs.yahoo.com/info/terms/> . > > > > ________________________________ > -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/