Selection

This section is dedicated to all properties, events and methods for handling selection on the JavaScript grid.

Documentation

Methods

Methods available to deal with the JavaScript grid selection
MethodDescription
getHighlightedGet the coordinates of the highlighted cells.
getHighlighted() : Array | null

getRangeGet the range description of the highlighted cells.
getRange() : String | null

selectAllSelect all cells.
selectAll() : void

updateSelectionSelect the cells from the coordinates of a DOM element.
updateSelection(e1: DOMElement, e2: DOMElement) : void

updateSelectionFromCoordsSelect the cells by coordinates.
updateSelectionFromCoords(x1: Number, y1: Number, x2: Number, y2: Number) : void

resetSelectionRemove the selection.
resetSelection() : void

isSelectedVerify if the coordinates given are included in the current selection.
isSelected(x: Number, y: Number) : Boolean



Events

EventDescription
onbluronblur(worksheet: Object) : void
onfocusonfocus(worksheet: Object) : void
onselectiononselection(worksheet: Object, x1: Number, y1: Number, x2: Number, y2: Number, e: MouseEvent) : void


Initial Settings

PropertyDescription
selectionCopy: booleanDisable the clone selection.


Examples

Select all worksheet cells in the grid programmatically.





Source code

<html>
<script src="https://jspreadsheet.com/v8/jspreadsheet.js"></script>
<script src="https://jsuites.net/v5/jsuites.js"></script>
<link rel="stylesheet" href="https://jspreadsheet.com/v8/jspreadsheet.css" type="text/css" />
<link rel="stylesheet" href="https://jsuites.net/v5/jsuites.css" type="text/css" />

<div id="spreadsheet"></div>

<button onclick="table[0].selectAll()">Select all</button>
<button onclick="table[0].updateSelectionFromCoords(2,2,3,3)">updateSelectionFromCoords(2,2,3,3)</button>

<script>
// Set the JSS spreadsheet license
jspreadsheet.setLicense('MTJlMDdjZjU0M2VkNzdkZDQwNjRhZjU3MWI1NmNjMGM5Yjk3ZmI3ZTA5Zjg4MGEzNzJlMTkzY2Q4NzVlZmU4NWZhMDA4MzRkNGNlOTZhODhjOTk4NDliMGY5NDVlMTY0NjA5Yjg0NTJmOWVjN2U1YmQ5YTBlZjEwNjE3Yjc4OTYsZXlKdVlXMWxJam9pU25Od2NtVmhaSE5vWldWMElpd2laR0YwWlNJNk1UY3hNVGN3TURNNU1pd2laRzl0WVdsdUlqcGJJbXB6Y0hKbFlXUnphR1ZsZEM1amIyMGlMQ0pqYjJSbGMyRnVaR0p2ZUM1cGJ5SXNJbXB6YUdWc2JDNXVaWFFpTENKamMySXVZWEJ3SWl3aWQyVmlJaXdpYkc5allXeG9iM04wSWwwc0luQnNZVzRpT2lJek5DSXNJbk5qYjNCbElqcGJJblkzSWl3aWRqZ2lMQ0oyT1NJc0luWXhNQ0lzSW1Ob1lYSjBjeUlzSW1admNtMXpJaXdpWm05eWJYVnNZU0lzSW5CaGNuTmxjaUlzSW5KbGJtUmxjaUlzSW1OdmJXMWxiblJ6SWl3aWFXMXdiM0owWlhJaUxDSmlZWElpTENKMllXeHBaR0YwYVc5dWN5SXNJbk5sWVhKamFDSXNJbkJ5YVc1MElpd2ljMmhsWlhSeklsMHNJbVJsYlc4aU9uUnlkV1Y5');

// Create the spreadsheet
var table = jspreadsheet(document.getElementById('spreadsheet'), {
    worksheets: [{
        minDimensions: [6,6],
    }],
});
</script>
</html>