:: Forum >>

How can get back all data of a row in variable

Hi,

I need to do this to build a external command which will be execute later.
I'd like to have an array with all data of each cells of a row.
How can do this ?

Thank's.

Ps: Sorry for my english, it'is not my usual language !!
Stephane
Friday, September 10, 2004
Here is the Template I wrote to Solve this problem.

My.Templates.RowAware = Active.System.Template.subclass();

My.Templates.RowAware.create = function(){

/****************************************************************
This template knows how to find the values from other columns
from within it's own row. It provides no content, and is
meant to be a base class for other "RowAware" template
subclasses.
*****************************************************************/


    var obj = this.prototype;
    var _super = this.superclass.prototype;

obj.__templateText = "{$}";
obj.getTemplateText = function(){ return this.__templateText; }
obj.setTemplateText = function( t ){ this.__templateText = t; }

obj.setContent("html", function() {
return this.resolveColumns( this.__templateText );
});

// ------------------------------------------------------------
// Performs search and replace on the regular expression /\{(\d+)\}/g;
// (eg {0} -> 0 ) and replaces the value with it's referenced column's
// text value.
//
// todo: how do you get the unformatted column value???
// ------------------------------------------------------------
obj.resolveColumns = function( str ) {
var r = this.getRowProperty("index");
var c = this.getColumnProperty("index");
var t = this.getItemProperty( "text" );
if (this.$owner) {
var results, row = this.$owner;
var pattern = /\{(\d+)\}/;
while (results = pattern.exec(str)) {
var colIndex = results[1];
var colValue = this.getColumnValue( colIndex );
if(!colValue) colValue = "";
str = str.replace( results[0], colValue );
}
}
str = str.replace(/{\$}/, t);
str = str.replace(/{row}/, r).replace(/{col}/,c);
return str;
}

obj.getColumnValue = function( colIndex ) {
var v = "";
if (this.$owner) {
v = this.$owner.getDataProperty( "text", colIndex );
}
return v;
}

};

My.Templates.RowAware.create();


then you can have the value from any column in the row as part of you generated HTML for the current cell.


Eg, this creates an anchor that alerts the value of column 0 in the current row, {$} gets replaced with the current cell data value.

var t = My.Templates.RowAware();
t.setTemplateText("<a href=\"javascript:alert('{0}');\">{$}</a>");
gbegley
Friday, September 10, 2004
See also this thread:

http://www.activewidgets.com/messages/2091-1.htm
Alex (ActiveWidgets)
Saturday, September 11, 2004
It's ok !!

thank's all
Tuesday, September 14, 2004
Hi,
I have a problem to access the data of each cells in the selection row.

does anyone knows how to do this?


Thank
ChamRoeun
Thursday, August 4, 2005

This topic is archived.


Back to support forum

Forum search