Spread for ASP.NET 11 Product Documentation
GetSelectedRanges
Spread for ASP.NET 11 Product Documentation > Client-Side Scripting Reference > Scripting Members > Methods > GetSelectedRanges

Gets the ranges of cells that are selected on the displayed page.

Syntax

[JavaScript]

var range = FpSpread1.GetSelectedRanges();

Parameters

None

Return Type

The return type is an array of selected ranges. The returned value is a JavaScript object that contains elements with the following properties: type, row, column, rowCount, and columnCount. The row and column properties are the indexes of the starting cell in the range. The rowCount and columnCount are the number of rows and columns in the range. The type property, which specifies the type of range, can be one of the following: Cell (if range is a range of cells but not entire rows or columns), Row (if range is an entire row or multiple rows) or Column (if range is entire column or multiple columns).

Remarks

This method gets the entire range of selected table cells as a JavaScript object.

Example

This is a sample that contains the method. Use the array length to get the number of elements. Use the array index property to get the properties of a single element in the array. On the client side, the script that contains the method would look like this:

JavaScript
Copy Code
<script type="text/javascript">
   function showSelection() {
     var s = document.getElementById("FpSpread1");
     var rgs = s.GetSelectedRanges();
     for (var i=0; i<rgs.length; i++) {
       var rg = rgs[i];
       alert(rg.row+", "+rg.col+", "+rg.rowCount+", "+rg.colCount);
     }
   }
</script>
See Also