3.2.0

Context menu on header

anyone got a context menu working on the header. I can get the menu to pop up the sort action still happens,

I want the behaviour to be

1. left click = sort
2. right click = context menu
eldiablo
September 11,
Replace mousedown event handler -

var header = new Active.Templates.Header;

    header.setEvent("onmousedown", function(event){
        if (event.button == 2 ) {
            alert("rightClicked");
        }
        else {
            this.setClass("header", "pressed");
            this.timeout(function(){this.action("columnSort")});
        }
    });

    obj.setTemplate("top/item", header);
Alex (ActiveWidgets)
September 11,
If you mean, defining a different context menu for each header, instead of a global for all headers. Then:

function headerClickedfunc(e)
{
var botonfunc = e.srcElement.id;
var posbotonfunc = botonfunc.indexOf(":" ,9)
var numbotonfunc = botonfunc.charAt(posbotonfunc+1);
if(numbotonfunc=="1"){
alert(" header-1 rightClicked");
}
else {this.setClass("header", "pressed");this.timeout(function(){this.action("columnSort")});} }

if (event.button == 2 ) { alert("header-2 rightClicked");}
else { this.setClass("header", "pressed"); this.timeout(function(){this.action("columnSort")}); } }
objfunc.getTemplate("top/item").setEvent("onmousedown", headerClickedfunc);

Carlos
September 14,
Sorry copy-paste error.

function headerClickedfunc(e)
{
var botonfunc = e.srcElement.id;
var posbotonfunc = botonfunc.indexOf(":" ,9)
var numbotonfunc = botonfunc.charAt(posbotonfunc+1);
if(numbotonfunc=="1"){if (event.button == 2 ) { alert("header-1 rightClicked");}
else { this.setClass("header", "pressed"); this.timeout(function(){this.action("columnSort")}); } } }
if(numbotonfunc=="2"){if (event.button == 2 ) { alert("header-2 rightClicked");}
else { this.setClass("header", "pressed"); this.timeout(function(){this.action("columnSort")}); } } }
}
objfunc.getTemplate("top/item").setEvent("onmousedown", headerClickedfunc);

Carlos
September 14,
I know this is a "dirty" work-around, If someone knows the cleaner one, Please Post.
Thanks
Carlos
September 14,
I just notice that "this" only works for less than eleven (0 to 9) headers, so I correct it for more than ten.
Thanks

// disable sort in grid1 and assign to each header button another event (function call))
obj1.getTemplate("top/item").setEvent("onmousedown", headerClickedfunc);


// function ( line above))
function headerClickedfunc(e) {

var botonfunc = e.srcElement.id;
var posbegbf = botonfunc.indexOf(":" ,9);
var posendbf = botonfunc.indexOf("/" ,9);
var numbotonfunc = botonfunc.substring((posbegbf+1),(posendbf));

if(numbotonfunc=="0"){}
// PUT HERE THE "PARTICULAR" FUNCTION (THIS COLUMN-HEADER CLICKED)
if(numbotonfunc=="1"){}
if(numbotonfunc=="2") {}
if(numbotonfunc=="3") {}
if(numbotonfunc=="4") {}

// PUT HERE THE "GENERIC" FUNCTION (ANY HEADER CLICKED)
}

//********************************
Carlos
November 17,

This topic is archived.

See also:


Back to support forum