Convert the GetSelectedCells array into string

Hi,

I would like to have in the client function handling the OnCellSelectedClientFunction event, a way to convert the array returned by the getSelectedCells
as a list of cell coordenades.

The code would somthing like:

function onCellSelected(cell)
{
var cls=this.getSelectedCells();
var values;
if (cls==null)
values=this.getActiveColumn()+';'+this.getActiveRow();
else
{
var i;
for(i in cls)
{
values=values+i.getCellColumn()+';'+i.getCellRow()+'|';
}
}

SetObjectValueById("lblSelection",values)
}

But, it should work!!!! And my code doesn't.
Can you please help?

António Carvalho

I've changed the script to:

function onCellSelected(cell)

{

var cls=this.getSelectedCells();

var values;

if (cls==null)

values=this.getActiveColumn()+';'+this.getActiveRow();

else

{

var i;

for(i in cls)

{

values=values+this.getCellColumn(i)+';'+this.getCellRow(i)+'|';

}

}

SetObjectValueById("lblSelection",values)

}

But it still doesn't work... I'm getting null, and other strange values...

António

Hi,

Currently you can't get the selected range in the cellselected event. You may get the selected range in a button click event. We will fix this issue soon.

Thank you for considering Aspose.

Hi,

If I could get the coordinates for the selection range, that would do. I don't really need a cell by cell list.

Can you please tel me how can I change my code to have the begin and end cells?

Thanks for your time.

António

Hi,

Thanks for considering Aspose.

The following way can be utilized to get the selected cells.

Example:

In html source, please set the onSubmit client side event,
E.g.,


And add a client side javascript function in
E.g.,

Thank you.

Hi,

Can I use this code in the OnCellSelectClientFunction handler?

António

Hi,

Well, you can't use onCellSelected event for getting the selected range of cells. Actually this event is fired when the first cell in the cells range is selected.

Thank you.

Hi,

Probably you can tell me if there is another way to do what I want.

I need to do some operatation with the selected cells after the user click some button (outside the grid command). Now, when the user does the click, the page will reload (due to the postback) and I lose the selection range. I would need to store that information, so I can performe my operation with the cells.

Do you have any suggestion?

António Carvalho

Hi,

We will get back to you soon.

Thanks for being patient!

Hi,

You can get the selected range at server side and process them. Just use GridWeb.SelectedCells property to get the collection of the selected cells. Each item of this collection is an ArrayList which contains cells in one selected row.

If you are using a button outside of the grid, you should add some client side code to let the button update the grid's postback data when it is clicked.

Button1.Attributes["onclick"] = "GridWeb1.updateData(); return GridWeb1.validateAll();";

Please see the online demo to get detail information about this behavior:

http://www.aspose.com/Products/Aspose.Grid/demos/Scripting/ClientSideScripting.aspx

Thank you for considering Aspose.