3.2.0

onClick event handler question


Hi Folks,

I have a question regarding the onClick even handler. Specifically, I have a code snipped like this:

function clickHander(src){
            var index = src.getProperty("row/index");
        alert('you clicked on row' + index);
    }

    // set click action handler
    obj.setAction("click", clickHandler);


I also have a grid with 3 columns that take up the left 2/3 or so of the grid "space". the Right 1/3 of the grid is empty e.g. there's no column there.

If I click on one of the columns, the grid moves the focus line to the appropriate row and runs my handler just like I'd expect.

If I, however, click on the "dead" space to the right (still within the grid but not a column), the focus line moves to that row, but my handler doesn't run.

Is there a way to either A) make my handler run nomatter where in the row a user clicks, B) prevent clicks in the "dead" space from moving the focus line?
pcasey@earthlink.net
April 2,
Alternate question:

Is there a way to determine how wide the grid is after it's drawn? If I could determine the width of the working area in pixels, it's trivial for me to resize all my columns to use all available space and hence avoid the "dead space" trap described above.

Since I'm using the default 100% width for the grid though, I can't seem to find a way to figure out how many actual pixels I have to work with. Is there a property or something I could interrogate?
pcasey@earthlink.net
April 3,
The solution appears to be to not use the onClick event handler but rather to use the selectionChanged handler instead.

function test(src){
    
        var index = this.getProperty("selection/index");
        alert('you clicked on row' + index);
    }

    // set click action handler
    obj.setAction("selectionChanged", test);
pcasey@earthlink.net
April 3,
If you want to inspect actual properties of grid html you can get access to it through element() method:

var el = obj.element();
alert(el.offsetWidth);

If grid is not yet written - element() method returns null.
Alex (ActiveWidgets)
April 4,

This topic is archived.

See also:


Back to support forum