App.mxml
------------------
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" >
<mx:DataGrid dataProvider="{sampleArray}" width="100%" editable="false">
<mx:columns>
<mx:Array>
<mx:DataGridColumn columnName="name" headerText="Name"/>
<mx:DataGridColumn columnName="password" headerText="Password" cellRenderer="SampleRenderer" />
</mx:Array>
</mx:columns>
</mx:DataGrid>
<mx:Button click="showPasswords()" label="Show Passwords" />
<mx:Script>
<![CDATA[
import SampleRenderer;
private var sampleArray:Array = new Array({name:"dick", password:"something"}, {name:"jane", password:"also_something"});
private function showPasswords():Void
{
var tmpString:String = "";
for(var i:Number = 0; i < sampleArray.length ; i++)
{
tmpString += "password for " + sampleArray[i].name + " = " + sampleArray[i].password + "\n";
}
mx.controls.Alert.show (tmpString);
}
]]>
</mx:Script>
</mx:Application>
SampleRenderer.mxml
-----------------------------------
<mx:HBox xmlns:mx=" http://www.macromedia.com/2003/mxml" width="100%" height="100%" horizontalAlign="left"
mouseDownSomewhere="setEditFalse(event)" hScrollPolicy="off" vScrollPolicy="off">
<mx:TextInput id="textinput" text="{itemString}" password="true" change="setItemProperty(event)" width="0" keyDown="checkKeyDown(event)" visible="false" />
<mx:Text id="passworddisplay" text="{passwordString}" selectable="false" mouseDown="setEditTrue(event)" width="100%" />
<mx:Script>
<![CDATA[
public var listOwner:MovieClip;
public var itemString:String;
public var passwordString:String;
private var dataGridItem:Object;
private var showTextInput:Boolean = false;
function setValue(str:String, item:Object)
{
if (item == undefined)
{
return;
}
dataGridItem = item;
itemString = String(item.password);
setPasswordString();
}
private function setItemProperty(event:Object):Void
{
dataGridItem.password = event.target.text;
itemString = event.target.text;
setPasswordString();
}
private function setEditTrue():Void
{
textinput.visible = true;
textinput.width = textinput.parent.width;
passworddisplay.width = 0;
passworddisplay.visible = false;
showTextInput = !showTextInput;
}
private function checkKeyDown(event:Object):Void
{
if(textinput.visible == true && event.code == Key.ENTER)
{
setEditFalse(event);
}
}
private function setEditFalse(event:Object):Void
{
textinput.visible = false;
textinput.width = 0;
passworddisplay.width = passworddisplay.parent.width ;
passworddisplay.visible = true;
showTextInput = !showTextInput;
}
private function setPasswordString():Void
{
var tmpString:String = "";
for(var i:Number = 0; i < itemString.length; i++)
{
tmpString += "*";
}
passwordString = tmpString;
}
]]>
</mx:Script>
</mx:HBox>
Brendan
On 6/22/06,
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
Well yes and no. The clear text password is still visable while the user is typing it in, the cell renderer does not get invoked to render the password invisible until after the user changes focus to another cell.
Brendan Meutzner <[EMAIL PROTECTED]> wrote:This could be accomplished using the cellRenderer property for DataGridColumn in 1.5.
On 6/21/06, [EMAIL PROTECTED] < [EMAIL PROTECTED]> wrote:We are using flex 1.5, I think this is a flex 2.0 feature. Is there another way to accomplish this?
Jason Szeto < [EMAIL PROTECTED] > wrote:You need to create a TextInput with password for your itemEditor as well.Jason
From: [email protected] [mailto:[email protected]] On Behalf Of jfournet
Sent: Thursday, June 15, 2006 6:13 PM
To: [email protected]
Subject: [flexcoders] Blank out password field in a datagrid cellHow can I blank out a password field in a datagrid cell. I have tried
using a text_input field in a cell renderer with the password property
set to true, but the clear text password is visable until the focus
goes off the cell then the **** are displayed. Any ideas, and code
samples?
Do you Yahoo!?
Get on board. You're invited to try the new Yahoo! Mail Beta.
__._,_.___
--
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 Computer software development Software design and development Macromedia flex Software development best practice
YAHOO! GROUPS LINKS
- Visit your group "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
__,_._,___
- Re: [flexcoders] Blank out password field in a datagrid c... Brendan Meutzner
Reply via email to

