TSService.setTableSelection

Syntax

setTableSelection (wbk, selectedIndexSeries, selectedIndexCols, callback, selection, left, top, width, height);

Parameters

wbk. Sets workbook, an instance of the Workbook class.

selectedIndexSeries. Sets array of indexes of the table series.

selectedIndexCols. Sets array of table column indices.

callback. Sets handler for operation execution end

selection. Selection to be set.

left. Sets index of the left cell in selection.

top. Sets index of the topmost cell in selection.

width. If the table is rotated table width is estimated ignoring fixed areas, otherwise it always equals to 1.

height. If the table is rotated, the value always equals to one, otherwise the table height is calculated ignoring fixed areas.

Description

The setTableSelection method sets selection in a table.

Example

To execute the example, the page must contain the WorkbookBox component named workbookBox (see Example of Creating the WorkbookBox Component), the open workbook must contain at least three rows and at least four columns, and the following code must be added in the document opening event handler:

var setTableSelectionButt = new PP.Ui.Button({
	ParentNode: document.body, //DOM parent node
	Content: "Select", //Text
	Click: PP.Delegate(onClickTableSelection)
});
function onClickTableSelection()
	{
		var source = workbookBox.getSource().getActiveSheet();//return an instance of the PP.TS.Workbook class
		var selectedIndexSeries = [0,1,2];
		var selectedIndexCols  = [2,4]
		var selection = {"range": {}, "type": "Normal"};
		selection.range =
			{
				"height": 0,
				"left": 0,
				"parts": {},
				"top": 0,
				"type": "MultiPart",
				"width": 0
			}
		selection.range.parts = {it : []};
		selection.range.parts.it.push(
			{
				"height": 3,
				"left": 11,
				"top": 1,
				"type": "Cells",
				"width": 3
			});
		var left = 1;
		var	top = 1;
		var	width = 1;
		var	height = 3;
		//Set selection in table
		tsService.setTableSelection(source, selectedIndexSeries, selectedIndexCols, PP.Delegate(onResponse), selection, left, top, width, height);
		function onResponse(sender, args)
			{
				var wbk = args.Args.Workbook;
				var minSer = Math.min.apply(null, wbk.getSelectedIndexSeries())+1;
				var maxSer = Math.max.apply(null, wbk.getSelectedIndexSeries())+1;
				var minCols = Math.min.apply(null, wbk.getSelectedIndexCols());
				var maxCols = Math.max.apply(null, wbk.getSelectedIndexCols());
				var gv = workbookBox.getDataView().getGridView();
				var selection = gv.getSelection();
				gv._GridSelection._SelectedAreas[0].Range._Corners.blCoord.colIndex = minCols;
				gv._GridSelection._SelectedAreas[0].Range._Corners.blCoord.rowIndex = maxSer;
				gv._GridSelection._SelectedAreas[0].Range._Corners.brCoord.colIndex = maxCols;
				gv._GridSelection._SelectedAreas[0].Range._Corners.brCoord.rowIndex = maxSer;
				gv._GridSelection._SelectedAreas[0].Range._Corners.tlCoord.colIndex = minCols;
				gv._GridSelection._SelectedAreas[0].Range._Corners.tlCoord.rowIndex = minSer;
				gv._GridSelection._SelectedAreas[0].Range._Corners.trCoord.colIndex = maxCols;
				gv._GridSelection._SelectedAreas[0].Range._Corners.trCoord.rowIndex = minSer;
				workbookBox.getDataView()._TabStatPanel.expand();
				workbookBox.getDataView()._TabStatPanel.collapse();
			}
	}

After executing the example a button named Select is placed in the HTML page. Clicking this button selects cells specified in parameters of the setTableSelection method:

See also:

TSService