:: Forum >>

Expand Combo TEMPLATE by clicking anywhere on it

Hi again. According to this thread: http://www.activewidgets.com/javascript.forum.9294.19/dropdown-control-instead-of-combo.html, you can tweak an AW.UI.Combo object to expand when you click anywhere on it, not just on the "v". This can be done as follows:

obj.onControlClicked = function() {
this.showPopup();
}

However, this doesn't seem to work when using the Combo TEMPLATE (AW.Templates.Combo) as the cell template for grid cells; is there a way to get the same effect there?
Jared
Friday, December 28, 2007
Here an example showing how to do that:
var obj = new AW.UI.Combo;
    obj.getContent('box/text').setAttribute('readonly', true);
    obj.getContent('box/text').setAttribute('autocomplete', 'off');
    obj.getContent("box")._innerHTML = "";
    obj.getContent("box")._outerHTML = "";
    obj._innerHTML = "";
    obj._outerHTML = "";
    if(AW.ie) obj.onControlActivated = function(){ return true; };

    obj.onControlClicked = function() { this.showPopup(); };
obj.onControlEditStarted = function(){ this.getContent("box/text").element().contentEditable = false; this.showPopup(); };


Hope this help.
Monday, December 31, 2007
Um......that's exactly what I just posted. Your example code uses AW.UI.Combo, which I already saw in the existing samples. What I need is a way to do it for AW.Templates.Combo. Can this be done?
Jared
Wednesday, January 2, 2008
For anyone interested, I think I've figured this out. My solution was to forget about the individual dropdowns' onControlClicked handlers, and instead use the grid's onCellClicked event handler in conjunction with custom attributes, like so:

var combo = new AW.Templates.Combo;
grid.setCellTemplate(combo, 3);

grid.onCellClicked =
function(event, col, row)
{
if (col == 3)
{
var cellTemplate = this.getCellTemplate(col, row);
if ((cellTemplate.getAttribute("expanded") == null) ||
(cellTemplate.getAttribute("expanded") == false))
{
cellTemplate.setAttribute("expanded", true);
cellTemplate.showPopup();
}
else
{
cellTemplate.hidePopup();
cellTemplate.setAttribute("expanded", false);
}
}
return true;
};
Jared
Wednesday, January 2, 2008

This topic is archived.


Back to support forum

Forum search