:: Forum >>

Formatting columns???

Hi,
Is there any way to specify the format of each column like number, currency, timestamp etc.
Thanks in advance.
a very impressed user
Thursday, January 15, 2004
No, the default cell template (Active.Templates.Text) will just take a text from the data model and put it on screen. If you need to present your data with specific formatting - you need to supply the formatted text to the grid.setDataText() method. You may also supply your raw data into the grid.setDataValue() - this will be used for sorting, so your formatting will not affect the sort order.

It is made this way because formatting with client-side script is relatively slow. You will get much better performance if you make formatting on the server and send the data to the client in 'ready-for-display' form.

However you can do the formatting on the client-side as well. ActiveWidgets has two classes which can help: Active.Formats.Number and Active.Formats.Date. There is also an example how you can use them with XML data model (/examples/grid/xml - array of records.htm)

Here is how you can format the date using Active.Formats.Date class:

var shortDate = new Active.Formats.Date;
shortDate.setTextFormat("DD-MMM");

var date = (new Date).getTime(); //date as milliseconds from 1.1.1970
var text = shortDate.valueToText(date);

alert(text);

Alex (ActiveWidgets)
Saturday, January 17, 2004
Thanks
Monday, January 19, 2004
Alex - is there a way to do a "custom" type of format in addition to the built in Active Formats classes? I am using an XML source so the many examples using javascript arrays have been difficult to convert.
Mike
Tuesday, May 10, 2005
Yes, you just have to provide your own valueToText or dataToText functions (starting from Active.System.Format class)
Alex (ActiveWidgets)
Wednesday, May 11, 2005
Got it working. This control is SWEET! Thanks, just needed a little direction.
Mike
Wednesday, May 11, 2005
If a data field in a CSV file is blank, the cell will automatically fill with
" undefined ". I can't code to save my life.
Is there a way to have those blank fields show up as just blank?
Help!!
Presto
Wednesday, June 1, 2005
holy !@#!.
Thx guys.
You have my graditude.
-Tinks-
Wednesday, June 1, 2005
I have same problem,
How to format data when we are reading from a CSV file???
kevin (TLI)
Saturday, July 30, 2005

This topic is archived.


Back to support forum

Forum search