:: Forum >>
How to Format the data of JavaScript Array?
Like for XMl.table we can do by
table.setFormats([string, string1, string2, string3, string4,date1, date2]);
how do i set the same formatting for an javascript Array.
like DataArray.setFormats([string, string1, string2, string3, string4,date1, date2]); This gives error.
Shyam
Wednesday, March 24, 2004
Please Reply me As i need it very urgently Please help me..
Shyam
Thursday, March 25, 2004
You will get better performance if you do number/date formatting on the server side. However you can still do it with the JS array and the same formatting classes. You just need to modify getDataText function:
// create and configure formatting objects
var string = new Active.Formats.String;
var number = new Active.Formats.Number;
number.setTextFormat("$ #.##");
// arrange all formatting objects into the single array
formats = [string, string, string, string, number];
...
// modify data/text procedure to return formatted data
obj.setDataText(function(i, j){return formats[j].dataToText(myData[i][j])});
- use dataToText method of the formatting object to transform data from storage/wire format to readable text.
Alex (ActiveWidgets)
Thursday, March 25, 2004
And this will do formatting to 'data/value' also - right?
But we can partly rely on default text to value conversion
obj.defineDataProperty("value", function(i,j){
var text = "" + this.getDataText(i, j);
var value = Number(text.replace(/[ ,%\$]/gi, "").replace(/\((.*)\)/, "-$1"));
return isNaN(value) ? text.toLowerCase() + " " : value;
});
I hope you are going to change grid to make this easy.
Sudhaker Raj
Monday, September 13, 2004
I am thinking of adding 'data/format' property for js array data model the same way as it works for XML. Is it the right solution? What do you think?
Alex (ActiveWidgets)
Sunday, September 19, 2004
I think that you should.
Here's a real-world use/need and I would like to know asap if there is already a solution.
I convert an ADO Recordset to a javascript array for use with the grid.
Once or more of the columns needs to display text which is a DATE.
That date is ALSO a hyperlink to another document.
The problem I have now is when I specify the format of the column as a DATE, it breaks, since the data/value of that column actually contains the hyperlink and the grid cannot seem to convert it to a valid date.
Is there a way to hyperlink a date and also be able to sort the same column correctly?
Michael
p.s. Love the grid, just not the docs~! ;-}
Hyperlinked Date column sorting
Monday, October 11, 2004
Alex (ActiveWidgets)
Monday, October 11, 2004
Hi Alex! Can you help me?
(Sorry about my English)
Like your reply, I did
// create and configure formatting objects
var string = new Active.Formats.String;
var number = new Active.Formats.Number;
number.setTextFormat("$ #.##");
// arrange all formatting objects into the single array
formats = [string, string, string, string, number];
...
// modify data/text procedure to return formatted data
obj.setDataText(function(i, j){return formats[j].dataToText(myData[i][j])});
But it don't understand j variable (formats[j]). If I write: formats[0] or
formats[1],... then OK. Is any solution?
Khuc Thuy Du
Friday, January 7, 2005
This topic is archived.
Back to support forum
Forum search