:: Forum >> Version 1 >>

Get selected column-1 text for multi-selection

I know the following code can get selected index [ by this.getProperty("selection/values") ]
//=========================
var message = function(){
window.status = "Grid selection:" +
" latest=" + this.getProperty);
document.write(obj);("selection/index") +
" full list=" + this.getProperty("selection/values") +
" (press Ctrl- to select multiple rows)."
}

obj.setAction("selectionChanged", message);
//=========================

But how can I get selected text ( for example: I want to get column 1 text of multi-selected rows) ?

I had see:
//============
function mySelect(){
var index = this.getSelectionProperty("index");
var text = this.getDataProperty("text", index, 1);
alert(text);
}

obj.setAction("selectionChanged", mySelect);
//=============
Can get selected text of column1.
But it only for single-select.

Please help me!
But how can I get selected text ( for example: I want to get column 1 text of multi-selected rows) ?
Thanks!

Rex Chen
Thursday, March 18, 2004
In case of multiple selection this.getProperty("selection/values") returns the array of indices of selected rows. You can loop through the array and get the actual data like this:

var array = this.getProperty("selection/values");
for (var i=0; i<array.length; i++){
var text = this.getDataProperty("text", array[i], 1);
...
}
Alex (ActiveWidgets)
Saturday, March 20, 2004
There is always a alarm pop out when this sentence occur.

var array = this.getProperty("selection/values");
e-Jonathan
Friday, December 24, 2004
Alex's code gives always undefined...
Kilian
Monday, August 1, 2005
Please help, I need to get the text of all the selected rows...
Kilian
Monday, August 1, 2005
No one knows how can I do it?
Kilian
Tuesday, August 2, 2005
I'm still waiting too...
Nailic
Wednesday, August 3, 2005
excellent widget, only being let down by stroppy documentation
alex, your code needs changing to ...

var array = this.getProperty("selection/values");
var text;
for (var i=0; i<array.length; i++){
text += this.getDataProperty("text", array[i], 1);
...
}

i suspect there is a bug as this now works, but space delimiter, not comma

also please, please ... lets all stop using text and "text" for different things
alan m
Wednesday, August 3, 2005
The documentation is... well, is not as good as the widget itself.
I still get undefined with your code, alan m. I mean, I always get an array with undefined values.
HELP, PLEASE, I NEED IT!
Nailic
Thursday, August 4, 2005
This thread could give some help
http://activewidgets.com/javascript.forum.1832.4/style-visited-rows-differently.html
Thursday, August 4, 2005
And also, this one
http://activewidgets.com/javascript.forum.3241.2/multiple-selection-undo.html
Thursday, August 4, 2005
how to change the background color of the selected text....in html

actually i wanna change blue to black how to do that???
ravi
Tuesday, August 16, 2005
Hey people, relax a little. The documentation is, well, not as comprehensive as a javadoc and not as complete as what is in w3schools. But hey, the forum is good enough to make for it, we post our problems here and share our thoughts, then they do their best to help. We collaborate to help each other in this community. Anyways, you should seach the forum first before you post your problems.

I also encountered the same problem. Instead of waiting, I searched the forums, read some post here, combined some codes and made some experiments, then I came up with this solution...


var row = [];
function select(){
var index = obj.getSelectionIndex();
var value = obj.getSelectionValues();
row = new Array(obj.getSelectionCount());

for (var i=0; i<value.length; i++) {
row[i] = myData[value[i]];
}
}
obj.setAction("selectionChanged", select);
function selected() {
alert(row);
}


This returns the content of the selected rows in two-dimentional array. This is useful if you need to pass this selected rows to be processed simultaneously.

Hope this helps...
Romz
Sunday, September 18, 2005
Ooops, I forgot to include this little thing. Just include this to you HTML then click it to see the result after you selected some rows in your grid.

<button onclick="selected()">SELECT</button>
Romz
Sunday, September 18, 2005
Please look into the code which help you completly as required.

var values = []
function selected_values(){
var obj=document.getElementById('Branches');
alert(obj.length);
for (var i=0; i<obj.length; i++) {
if(obj.options[i].selected == true){
values[i] =obj.options[i].text
}
}
alert(values);
}
Avinash Hatwal
Tuesday, May 30, 2006



This topic is archived.

Back to support forum

Forum search