[flexcoders] How to set the datetime format in datagrid?

2008-04-03 Thread markflex2007
Hi,

I have a program the read datetime fields for SQL Server and show in
datagrid.

I do not know how to set the date format in datagrid (mx:DataGridColumn),

Please help me.

Please let me know if you have demo link.

Thanks.



Re: [flexcoders] How to set the datetime format in datagrid?

2008-04-03 Thread Muzak
Look up DataGridColumn.labelFunction and DateFormatter in the docs.

http://livedocs.adobe.com/flex/3/langref/mx/controls/dataGridClasses/DataGridColumn.html
http://livedocs.adobe.com/flex/3/langref/mx/formatters/DateFormatter.html

- Original Message - 
From: markflex2007 [EMAIL PROTECTED]
To: flexcoders@yahoogroups.com
Sent: Thursday, April 03, 2008 9:55 PM
Subject: [flexcoders] How to set the datetime format in datagrid?


Hi,

I have a program the read datetime fields for SQL Server and show in
datagrid.

I do not know how to set the date format in datagrid (mx:DataGridColumn),

Please help me.

Please let me know if you have demo link.

Thanks.





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! 
Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* Your email settings:
Individual Email | Traditional

* To change settings online go to:
http://groups.yahoo.com/group/flexcoders/join
(Yahoo! ID required)

* To change settings via email:
mailto:[EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED]

* 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/



RE: [flexcoders] How to set the datetime format in datagrid?

2008-04-03 Thread Alex Harui
There should be an example somewhere of hooking up a Formatter to a
column's labelFunction

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of markflex2007
Sent: Thursday, April 03, 2008 12:55 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] How to set the datetime format in datagrid?

 

Hi,

I have a program the read datetime fields for SQL Server and show in
datagrid.

I do not know how to set the date format in datagrid
(mx:DataGridColumn),

Please help me.

Please let me know if you have demo link.

Thanks.

 



[flexcoders] Re: How to set the datetime format in datagrid?

2008-04-03 Thread dougco2000
One way to display a human readable date in a datagrid and have it be
sortable, is to use labelFunction={convertDate} and have the server
send over unix milliseconds. This is important if you want to be able
to properly sort the column.

A sample function looks like:

private function convertDate(item:Object, column:DataGridColumn):String {
   var myDate:Date = new Date(item.Date);
   var months:Array = new Array();
   months = [, Jan, Feb, Mar, Apr, May, Jun, Jul,
Aug, Sep, Oct, Nov, Dec];
   var a:Array = new Array();
   var b:Array = new Array();

   a.push(myDate.getMonth());
   a.push(myDate.getUTCDate());
   a.push(myDate.getUTCFullYear());

   b.push(myDate.getUTCHours());
   b.push(myDate.getUTCMinutes());

   if (b[0]10) { b[0] = 0 + b[0] }
   if (b[1]10) { b[1] = 0 + b[1] }

   return months[parseInt(a[0])+1] + + a[1] +   + b.join(:);
} }


--- In flexcoders@yahoogroups.com, markflex2007 [EMAIL PROTECTED]
wrote:

 Hi,
 
 I have a program the read datetime fields for SQL Server and show in
 datagrid.
 
 I do not know how to set the date format in datagrid
(mx:DataGridColumn),
 
 Please help me.
 
 Please let me know if you have demo link.
 
 Thanks.





datetime format

2005-02-28 Thread Miguel Diaz Valenzuela

well, i´m again with another question to you coders

i have a datetime row, with following format: 25/02/2005 12:57:00

how can I format this one and change it in Macromedia Flex to this:
25/02/2005

thanks in advance for all reply







RE: [flexcoders] datetime format

2005-02-28 Thread Jeff Tapper
this can actually be done with a label function, no need for the cell 
renderer if all you want to do is change the text which is shown.

At 01:40 PM 2/28/2005, you wrote:
Here is a cell renderer that I use:
?xml version=1.0 encoding=iso-8859-1?
mx:Canvas 
xmlns:mx=http://www.macromedia.com/2003/mxmlhttp://www.macromedia.com/2003/mxml;
mx:Script
![CDATA[

function setValue(str:String, item:Object, sel:Boolean):Void {
date_txt.text = StandardDateFormat.format(item.date);
}
]]
/mx:Script
!-- Declare a formatter and specify formatting properties. --
mx:DateFormatter id=StandardDateFormat formatString=M/DD//
!-- Trigger the formatter while populating a string with data. --
mx:Text id=date_txt/
/mx:Canvas
Just change the formatString to how you want to format your date
-Original Message-
From: Miguel Diaz Valenzuela [mailto:[EMAIL PROTECTED]
Sent: Monday, February 28, 2005 12:39 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] datetime format

well, i´m again with another question to you coders
i have a datetime row, with following format: 25/02/2005 12:57:00
how can I format this one and change it in Macromedia Flex to this:
25/02/2005
thanks in advance for all reply


Yahoo! Groups Links



Yahoo! Groups Sponsor
ADVERTISEMENT
http://us.ard.yahoo.com/SIG=1298p00e0/M=298184.6018725.7038619.3001176/D=groups/S=1705007207:HM/EXP=1109702458/A=2593423/R=0/SIG=11el9gslf/*http://www.netflix.com/Default?mqso=60190075
click here

--
Yahoo! Groups Links
* To visit your group on the web, go to:
* 
http://groups.yahoo.com/group/flexcoders/http://groups.yahoo.com/group/flexcoders/ 

*
* To unsubscribe from this group, send an email to:
* 
mailto:[EMAIL PROTECTED][EMAIL PROTECTED] 

*
* Your use of Yahoo! Groups is subject to the 
http://docs.yahoo.com/info/terms/Yahoo! Terms of Service.




RE: [flexcoders] datetime format

2005-02-28 Thread Clint Tredway
I realized that after I did the cell renderer... I just havn't gone back 
tochange it to a label function yet... too busy :)

-Original Message-
From: Jeff Tapper [mailto:[EMAIL PROTECTED]
Sent: Monday, February 28, 2005 12:46 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] datetime format



this can actually be done with a label function, no need for the cell 
renderer if all you want to do is change the text which is shown.

At 01:40 PM 2/28/2005, you wrote:
Here is a cell renderer that I use:
?xml version=1.0 encoding=iso-8859-1?
mx:Canvas 
xmlns:mx=http://www.macromedia.com/2003/mxmlhttp://www.macromedia.com/2003/mxml;
 mx:Script
 ![CDATA[

 function setValue(str:String, item:Object, sel:Boolean):Void {
 date_txt.text = StandardDateFormat.format(item.date);
 }

 ]]
 /mx:Script
 !-- Declare a formatter and specify formatting properties. --
 mx:DateFormatter id=StandardDateFormat formatString=M/DD//

 !-- Trigger the formatter while populating a string with data. --
 mx:Text id=date_txt/

/mx:Canvas

Just change the formatString to how you want to format your date

-Original Message-
From: Miguel Diaz Valenzuela [mailto:[EMAIL PROTECTED]
Sent: Monday, February 28, 2005 12:39 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] datetime format




well, i´m again with another question to you coders

i have a datetime row, with following format: 25/02/2005 12:57:00

how can I format this one and change it in Macromedia Flex to this:
25/02/2005

thanks in advance for all reply






Yahoo! Groups Links








Yahoo! Groups Sponsor
ADVERTISEMENT
http://us.ard.yahoo.com/SIG=1298p00e0/M=298184.6018725.7038619.3001176/D=groups/S=1705007207:HM/EXP=1109702458/A=2593423/R=0/SIG=11el9gslf/*http://www.netflix.com/Default?mqso=60190075
click here



--
Yahoo! Groups Links
 * To visit your group on the web, go to:
 * 
 http://groups.yahoo.com/group/flexcoders/http://groups.yahoo.com/group/flexcoders/
  

 *
 * To unsubscribe from this group, send an email to:
 * 
 mailto:[EMAIL PROTECTED][EMAIL PROTECTED] 

 *
 * Your use of Yahoo! Groups is subject to the 
 http://docs.yahoo.com/info/terms/Yahoo! Terms of Service.



 
Yahoo! Groups Links



 







Re: datetime format

2005-02-28 Thread Miguel Diaz Valenzuela

ok, but what happen if datetime I want to format is on a datagrid?

--- In flexcoders@yahoogroups.com, Clint Tredway [EMAIL PROTECTED] wrote:
 Here is a cell renderer that I use:
 ?xml version=1.0 encoding=iso-8859-1?
 mx:Canvas xmlns:mx=http://www.macromedia.com/2003/mxml;
 mx:Script
 ![CDATA[
 
 function setValue(str:String, item:Object, sel:Boolean):Void {
 date_txt.text = StandardDateFormat.format(item.date);
 }
 
 ]]
 /mx:Script
 !-- Declare a formatter and specify formatting properties. --
 mx:DateFormatter id=StandardDateFormat formatString=M/DD//
 
 !-- Trigger the formatter while populating a string with data. --
 mx:Text id=date_txt/ 
 
 /mx:Canvas
 
 Just change the formatString to how you want to format your date
 
 -Original Message-
 From: Miguel Diaz Valenzuela [mailto:[EMAIL PROTECTED]
 Sent: Monday, February 28, 2005 12:39 PM
 To: flexcoders@yahoogroups.com
 Subject: [flexcoders] datetime format
 
 
 
 
 well, i´m again with another question to you coders
 
 i have a datetime row, with following format: 25/02/2005 12:57:00
 
 how can I format this one and change it in Macromedia Flex to this:
 25/02/2005
 
 thanks in advance for all reply
 
 
 
 
 
  
 Yahoo! Groups Links







RE: [flexcoders] Re: datetime format

2005-02-28 Thread Clint Tredway
just add this as that column's cell renderer
mx:DataGridColumn cellrenderer=dateFormat/

and save the cell renderer as dateFormat.mxml

One reason I use this as a cell renderer is because I can use this in multiple 
places with have the function in multiple places...

-Original Message-
From: Miguel Diaz Valenzuela [mailto:[EMAIL PROTECTED]
Sent: Monday, February 28, 2005 12:55 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: datetime format




ok, but what happen if datetime I want to format is on a datagrid?

--- In flexcoders@yahoogroups.com, Clint Tredway [EMAIL PROTECTED] wrote:
 Here is a cell renderer that I use:
 ?xml version=1.0 encoding=iso-8859-1?
 mx:Canvas xmlns:mx=http://www.macromedia.com/2003/mxml;
 mx:Script
 ![CDATA[
 
 function setValue(str:String, item:Object, sel:Boolean):Void {
 date_txt.text = StandardDateFormat.format(item.date);
 }
 
 ]]
 /mx:Script
 !-- Declare a formatter and specify formatting properties. --
 mx:DateFormatter id=StandardDateFormat formatString=M/DD//
 
 !-- Trigger the formatter while populating a string with data. --
 mx:Text id=date_txt/ 
 
 /mx:Canvas
 
 Just change the formatString to how you want to format your date
 
 -Original Message-
 From: Miguel Diaz Valenzuela [mailto:[EMAIL PROTECTED]
 Sent: Monday, February 28, 2005 12:39 PM
 To: flexcoders@yahoogroups.com
 Subject: [flexcoders] datetime format
 
 
 
 
 well, i´m again with another question to you coders
 
 i have a datetime row, with following format: 25/02/2005 12:57:00
 
 how can I format this one and change it in Macromedia Flex to this:
 25/02/2005
 
 thanks in advance for all reply
 
 
 
 
 
  
 Yahoo! Groups Links





 
Yahoo! Groups Links



 







Re: [flexcoders] Re: datetime format

2005-02-28 Thread Jeff Tapper
no problem. here is an example:
?xml version=1.0 encoding=utf-8?
mx:Application xmlns:mx=http://www.macromedia.com/2003/mxml; 
creationComplete=buildDP()
mx:Script
![CDATA[
var dp;
function buildDP(){
var item1:Object = new Object();
item1.name=jeff;
item1.dob = new Date(1970,11,17);
var item2:Object = new Object();
item2.name=lisa;
item2.dob = new Date(1968,7,23);
var item3:Object = new Object();
item3.name=kali;
item3.dob = new Date(2004,5,23);
dp = new Array(item1,item2,item3);
}
function formatDate(item:Object):String{
return formatter.format(item.dob);
}
]]
/mx:Script
mx:DateFormatter id=formatter/
mx:DataGrid dataProvider={dp}
mx:columns
mx:Array
mx:DataGridColumn columnName=name/
mx:DataGridColumn columnName=dob 
headerText=Date of Birth labelFunction=formatDate/
/mx:Array
/mx:columns
/mx:DataGrid
/mx:Application

At 01:54 PM 2/28/2005, you wrote:
ok, but what happen if datetime I want to format is on a datagrid?
--- In flexcoders@yahoogroups.com, Clint Tredway [EMAIL PROTECTED] wrote:
 Here is a cell renderer that I use:
 ?xml version=1.0 encoding=iso-8859-1?
 mx:Canvas 
xmlns:mx=http://www.macromedia.com/2003/mxmlhttp://www.macromedia.com/2003/mxml;
 mx:Script
 ![CDATA[

 function setValue(str:String, item:Object, sel:Boolean):Void {
 date_txt.text = StandardDateFormat.format(item.date);
 }

 ]]
 /mx:Script
 !-- Declare a formatter and specify formatting properties. --
 mx:DateFormatter id=StandardDateFormat formatString=M/DD//

 !-- Trigger the formatter while populating a string with data. --
 mx:Text id=date_txt/

 /mx:Canvas

 Just change the formatString to how you want to format your date

 -Original Message-
 From: Miguel Diaz Valenzuela [mailto:[EMAIL PROTECTED]
 Sent: Monday, February 28, 2005 12:39 PM
 To: flexcoders@yahoogroups.com
 Subject: [flexcoders] datetime format




 well, i´m again with another question to you coders

 i have a datetime row, with following format: 25/02/2005 12:57:00

 how can I format this one and change it in Macromedia Flex to this:
 25/02/2005

 thanks in advance for all reply






 Yahoo! Groups Links


Yahoo! Groups Sponsor
ADVERTISEMENT
http://us.ard.yahoo.com/SIG=129la1i5u/M=298184.6018725.7038619.3001176/D=groups/S=1705007207:HM/EXP=1109703288/A=2593423/R=0/SIG=11el9gslf/*http://www.netflix.com/Default?mqso=60190075
click here

--
Yahoo! Groups Links
* To visit your group on the web, go to:
* 
http://groups.yahoo.com/group/flexcoders/http://groups.yahoo.com/group/flexcoders/ 

*
* To unsubscribe from this group, send an email to:
* 
mailto:[EMAIL PROTECTED][EMAIL PROTECTED] 

*
* Your use of Yahoo! Groups is subject to the 
http://docs.yahoo.com/info/terms/Yahoo! Terms of Service.