:: Forum >>

Click on a row, and copy the second colum value of this row to the clipboard

Click on a row, and copy the second colum value of this row to the clipboard

For example
_|________|_______
1| Test | Test2
2| peter | max
.....

I click in "max" an becomes and I get "peter". If I click "on peter", I becomes "peter" too...
with "obj.setAction("click", function(src){editarticle.catnr.value = src.getDataProperty("text")});" I get the value where the mouse clicked. I will always the value of columm 2.



thx!
Steve
Tuesday, March 8, 2005
http://www.activewidgets.com/javascript.forum.3294.2/data-from-another-rows-columns.html
Alex (ActiveWidgets)
Tuesday, March 8, 2005
thx a lot!!!!!!
Steve
Wednesday, March 9, 2005
Hi Alex and Steve,
I have tried the example you refer to and it works. I would like however to move the code that shows the value to an external js file. The first step I took is to put in a seperate function
var gridUsers_columns = [
"First Name","Last Name","Department","Country"
]
var gridUsers_data = [
["myfirstname","mylastname","mydepartment","mycountry"]
];
try {
var gridUsers = new Active.Controls.Grid;
gridUsers.setRowCount(1);
gridUsers.setColumnCount(4);
gridUsers.setColumnText(function(i){return gridUsers_columns[i];});
gridUsers.setDataText(function(i,j){return gridUsers_data[i][j];});
function setForm(src) {
var rowIndex = src.getRowProperty("text");
var tekst = this.getDataProperty("text", rowIndex, 1);
alert(tekst);
}
gridUsers.setAction("click", setForm);
document.write(gridUsers);
}
catch(error) {
//show error in another frame
parent.bottombar.write("Grid error: "; error.description);
}

This also works fine. When I move this setForm function to a js file however things stop working. I get this error
line 71: 'gridUsers_data[...]' is null or not an object
I have tried to change the way I attach the function to the grid object by replacing
gridUsers.setAction("click", setForm);
in the above code by
var row = new Active.Templates.Row;
row.setEvent('onclick', function(){this.action("setFormAction")});
gridUsers.setTemplate("row", row);
gridUsers.setAction("setFormAction", setForm);

because I saw some people using this technique (although I don't understand what the difference is between both). I keep getting the same error however.
The grid tool works way to good to be the cause so I must be doing something wrong. Can you tell me what ??
Thanks in advance.
Roebie
Tuesday, March 15, 2005

This topic is archived.


Back to support forum

Forum search