:: Forum >>

Problem with selectionChanged event


I'm having some problems with the selectionChanged event. I want to be able to click on a row, then have the data in that row display someplace else. Here's the relevant section of my code:

function fdata()
var array = obj.getProperty("selection/values");
document.getElementById("asdf").innerHTML = array[0];



<div id="asdf" onClick="fdata()">test</div>

// create ActiveWidgets Grid javascript object
var obj = new Active.Controls.Grid;

// set number of rows/columns

// set grid to single selection
obj.setProperty("selection/multiple", false);

// provide cells and headers text
obj.setDataText(function(i, j){return myData[i][j]});
obj.setColumnText(function(i){return myColumns[i]});

var row = obj.getTemplate("row");
row.setEvent("onmouseover", "mouseover(this, 'active-row-highlight')");
row.setEvent("onmouseout", "mouseout(this, 'active-row-highlight')");


// write grid html to the page

If I click on the 'asdf' div, the fdata() function works fine. However clicking on a row in the grid does not fire fdata(). Could you tell me how to make this happen? Also - could you explain the difference between the setEvent and setAction functions, and when to use each of them?


Monday, January 5, 2004
Looks like the problem is in the syntax, it should be
obj.setAction("selectionChanged",fdata); // provide function ref, not
obj.setAction("selectionChanged",fdata()); // provide call result

The setEvent function assigns DOM event handler the similar way as if you write <div onclick="myFunction()"> except that the framework will translate reference to the DOM div object into your ActiveWidgets javascript object and call an event handler as a method of that object.

The setAction is something higher level - things like insert row, resize etc. Normally setEvent will catch the specific DOM event and translate into ActiveWidgets action. (the events/actions part of the grid api is in a very early stage, needs some work first).
Alex (ActiveWidgets)
Monday, January 5, 2004
Why is it always the simple things that you spend hours staring at, and yet don't see?
Thanks for the help.

Monday, January 5, 2004

This topic is archived.

Back to support forum

Forum search