:: Forum >>

Patching AW.UI modues itself


When I needed to all the Input box to behave the same way i just used AW.UI.Input.protoype = ... and it worked like a hell. All the input boxes was behaving the way I needed with no more need to patch each one itself.

Now i tried to implement Context menu to all the grids in my app using the same way... Tried to Patch AW.UI.Grid.prototype... But I got the error, that the object does not have this property or method...

What am I doing wrong ?

// html event handler translates to grid events
oncontextmenu = function(event){

// assign html event handler to header template
//AW.UI.Grid.prototype.getHeaderTemplate().setEvent("oncontextmenu", oncontextmenu);

// assign grid event handler
AW.UI.Grid.prototype.onHeaderContextMenu = function(event, col){

    var contextMenuContent = '';
contextMenuContent += '<a class="menuItem" href="javascript:customFunctionA('+row+')"><strong>Custom Function A</strong></a>';
    contextMenuContent += '<a class="menuItem" href="javascript:customFunctionB()">Custom Function B</a>';
    contextMenuContent += '<div class="menuItemSep"></div>';
    contextMenuContent += '<a class="menuItem" href="javascript:customFunctionC()">Custom Function C</a>';

Tuesday, August 1, 2006
This line
//AW.UI.Grid.prototype.getHeaderTemplate().setEvent("oncontextmenu", oncontextmenu);

is not commented in my script... it is the copy&Paste error... :D
Tuesday, August 1, 2006
All AW classes are created 'on demand' - the create() method is called when you create first instance of the class (using operator new). This is done to speed up loading/initialization - the classes are created only when they are needed by your code.

It means that AW.UI.Grid.prototype is empty until AW.UI.Grid.create() method is called, i.e. until the first statement like

var obj = new AW.UI.Grid;

You can do patching as you describe but you have to create an instance of the class first. Just put new AW.UI.Grid; before your code.

Or you can overload AW.UI.Grid.create() method.
Alex (ActiveWidgets)
Tuesday, August 1, 2006

This topic is archived.

Back to support forum

Forum search