3.2.0

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
March 18,
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)
March 20,
There is always a alarm pop out when this sentence occur.

var array = this.getProperty("selection/values");
e-Jonathan
December 24,
Alex's code gives always undefined...
Kilian
August 1,
Please help, I need to get the text of all the selected rows...
Kilian
August 1,
No one knows how can I do it?
Kilian
August 2,
I'm still waiting too...
Nailic
August 3,
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
August 3,
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
August 4,
This thread could give some help
http://activewidgets.com/javascript.forum.1832.4/style-visited-rows-differently.html
August 4,
And also, this one
http://activewidgets.com/javascript.forum.3241.2/multiple-selection-undo.html
August 4,
how to change the background color of the selected text....in html

actually i wanna change blue to black how to do that???
ravi
August 16,
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
September 18,
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
September 18,
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
May 30,

This topic is archived.

See also:


Back to support forum