3.2.0

Problem with selectionChanged event

Hello

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];

}

</script>

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

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

// set number of rows/columns
obj.setRowCount(num_rows);
obj.setColumnCount(12);

// 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')");

obj.setAction("selectionChanged",fdata());

// write grid html to the page
document.write(obj);

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?

Thanks

AlU
January 5,
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)
January 5,
<smack>
Why is it always the simple things that you spend hours staring at, and yet don't see?
Thanks for the help.

January 5,

This topic is archived.

See also:


Back to support forum