3.0 beta 2

Getting data of the selected row??

Hi,
Is there a way to get the data contained in the select row as an Array?
Thanks in advance
a very impressed user ;-)
January 5,
Grid widget doesn't know much about the data structures - the data model takes care of that. So if your data is available as array (as in /examples/grid/basic.htm) - you can get a row array using row index:

// create action handler
function printRowData(src){
// get index of the selected row
var index = src.getProperty("row/index");
// print data using the row index
window.status = myData[index];
}

// set click action handler
obj.setAction("click", printRowData);
Alex (ActiveWidgets)
January 5,
I want to use a button to copy the selected rows to the clipboard. I have everything working (via obj.setAction("selectionChanged", copyRowData);) but i can't figure out how to get a button click to do the same thing.

I tried this:

var button1 = new Active.HTML.BUTTON;
button1.setContent("html", "Copy");
button1.setEvent("onclick", copyRowData);
document.write(button1);

Can someone please explain how to do this or suggest another way. Any help appreciated.

Thanks,
Mark
markl
May 21,
I have a similar issue, but I need to get the data from a particular cell (field 0) on a row mouseover event. Basically, I need to set a global variable, but in this example, I am just using alert(). All I am able to get is the last row's data - not the currently highlight row. Here is what I have so far:

var obj= new Active.Controls.Grid;
obj.setRowCount(20);
obj.setColumnCount(37);
obj.setDataText(function(i, j){return obj_data[i][j]});
obj.setColumnText(function(i){return obj_columns[i]});
obj.setDataProperty("index", function(i){return obj_data[i][0]});
obj.setAction("click", function(src){alert(src.getItemProperty("index"))});
var row = new Active.Templates.Row;
row.setEvent("onmouseover", "alert(row.getItemProperty('index')); mouseover(this, 'active-row-highlight');");
row.setEvent("onmouseout", "mouseout(this, 'active-row-highlight');");
obj.setTemplate("row", row);
document.write(obj);
}
Jon
June 14,
The event handler which is supplied as a string is treated by the ActiveWidgets framework in a different way compared to the event handler which is a function. The string is evaluated directly on the DOM element, which is equivalent to assigning the string to the "onmouseover" HTML attribute.

When the event handler is supplied as a function then the framework first finds the original ActiveWidgets object (template + index) and executes the event handler as a method of this object.
Alex (ActiveWidgets)
June 14,
Thanks! Switching to a function-based event handler worked prefectly.
Jon
June 15,
Actually, there is a new issue. I can obtain the data I need, but now the row-highlighting portion does not work. Can I use the intrinsic row "mouseover" command along with a function reference? I tried simply adding another row.setEvent, but the second one overwrites the first. Basically, I need it to fire both of these events on a mouseover:

//mouseover events-----
row.setEvent("onmouseover", "mouseover(this, 'className');");
row.setEvent("onmouseover", function(){varId = this.getItemProperty("index")});

I tried moving the intrinsic "mouseover" call into the function separated by a semicolon, but the row-highlight still does not work. Is there any way to do both?
Jon
June 15,
You should add to your function something like this:
mouseover(this.element(), 'className');
Alex (ActiveWidgets)
June 15,

This topic is archived.

See also:


Back to support forum

Search

Version 2

Looking for AW 2.6 ?
The old site is here.