:: Forum >>

Alternative for AW.object(this.element().id)

Hello I am interested in using the same function handlers for all the grids.
so instead of using "myGrid" as the object I can use AW.object(this.element().id) as shown below

var myGrid = new AW.Grid.Extended;
...
myGrid.onCellTextChanged = cellTextChanged;
myGrid.onCellEditStarted = cellEditStarted;
...


example:

function cellTextChanged(text, column, row)
{
AW.object(this.element().id).setFooterText(text, column, 1);
AW.object(this.element().id).getFooterTemplate(column, 1).refresh();
};


instead of

function cellTextChanged(text, column, row)
{
myGrid.setFooterText(text, column, 1);
myGrid.getFooterTemplate(column, 1).refresh();
};


I have no idea which are the system resources used by this method and my question is that is it suitable for using it.
If no, which are the alternatives ?

I also want to get the instance of the input text used by AW to edit the cell. For now I use:

this.element().getElementsByTagName('INPUT')[0];

as in

function cellEditStarted(text, column, row)
{
var cellEd = this.element().getElementsByTagName('INPUT')[0];
cellEd.setAttribute('maxLength',5);// limit to 5 chars
cellEd.name = cellEd.id;//for viewing in FF Page information-Forms
};


which reads though the entire grid / spans.

PS: For the demonstration I have used a 2-footered Extended Grid with editable rows / cells and when editing I display the current text value to the 2nd footer cell that coresponds to that column... as testing purposes

Thanks in advance
Bogdan P.
Saturday, March 31, 2007
Do not use AW.object(this.element().id) - just use this instead. All control event handlers are executed in such way that keyword this refers to the control itself.

function cellTextChanged(text, column, row)
{
this.setFooterText(text, column, 1);
this.getFooterTemplate(column, 1).refresh();
};


var myGrid = new AW.Grid.Extended;
...
myGrid.onCellTextChanged = cellTextChanged;
myGrid.onCellEditStarted = cellEditStarted;
...


Note, that AW does not use INPUT tag for cell editing in IE (uses SPAN with contentEditable=true). You can get access to the editor tag this way -

function cellEditStarted(text, column, row)
{
// 'this' refers to the grid object
var cellObject = this.getCellTemplate(column, row);
var textObject = cellObject.getContent("box/text");
var textElement = textObject.element();
...
};

Alex (ActiveWidgets)
Saturday, March 31, 2007

This topic is archived.


Back to support forum

Forum search