:: Forum >>

Defining formats while retaining methods that updates JS Array

When using a templates that enables the user to edit values in a grid, one need to use the following code to ensure that the changes are also made to the JS Array:
obj.getDataText = function(i, j){return myData[i][j]};
obj.setDataText = function(value, i, j){myData[i][j] = value};


But what if you want to define formats for the various columns:
var str = new Active.Formats.String;
var date = new Active.Formats.Date;
var number = new Active.Formats.Number;
date.setDataFormat("auto");
date.setTextFormat("yyyy/mm/dd");
date.setErrorText("");
number.setTextFormat("###");
number.setErrorText("");

var formats = [number, number, number, number, number, number, str, str, str, str, str, str, date, date, str];


Normally one apply the above defined formats like so:
obj.setDataText(function(i, j){return obj[j].dataToText(myData[i][j])});
obj.setDataValue(function(i, j){return formats[j].dataToValue(myData[i][j])});


How will one apply the formats while retaining the ability to have changes saved to the JS Array
Neil Craig
Friday, June 2, 2006
Sorry, that last block of code should read:
obj.setDataText(function(i, j){return formats[j].dataToText(myData[i][j])});
obj.setDataValue(function(i, j){return formats[j].dataToValue(myData[i][j])});
Neil Craig
Friday, June 2, 2006

This topic is archived.


Back to support forum

Forum search