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
January 15,
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)
January 17,
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
May 10,
Yes, you just have to provide your own valueToText or dataToText functions (starting from Active.System.Format class)
Alex (ActiveWidgets)
May 11,
Got it working. This control is SWEET! Thanks, just needed a little direction.
Mike
May 11,
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
June 1,
holy !@#!.
Thx guys.
You have my graditude.
-Tinks-
June 1,
I have same problem,
How to format data when we are reading from a CSV file???
kevin (TLI)
July 30,