3.0 beta 2

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
March 24,
Please Reply me As i need it very urgently Please help me..
Shyam
March 25,
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)
March 25,

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
September 13,
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)
September 19,
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
October 11,
In addition to /datagrid.595/ I can suggest using a link template ("Active.Templates.Link") and provide text, image, value and link (url) separately.
Alex (ActiveWidgets)
October 11,

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
January 7,

This topic is archived.

See also:


Back to support forum

Search

Version 2

Looking for AW 2.6 ?
The old site is here.