:: Forum >> Version 2 >>

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(textcolumnrow)
{
  
AW.object(this.element().id).setFooterText(textcolumn1);
  
AW.object(this.element().id).getFooterTemplate(column1).refresh();
};
 
instead of

function cellTextChanged(textcolumnrow)
{
  
myGrid.setFooterText(textcolumn1);
  
myGrid.getFooterTemplate(column1).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(textcolumnrow)
{
   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(textcolumnrow)
{
  
this.setFooterText(textcolumn1);
  
this.getFooterTemplate(column1).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(textcolumnrow)
{
   
// 'this' refers to the grid object
   
var cellObject this.getCellTemplate(columnrow);
   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