getStartCoord();
The getStartCoord method returns an object with initial coordinates of table row selection.
The method returns object with the following fields:
colIndex. Name of the column that is clicked.
coordX. Coordinate X of the cell that is clicked.
coordY. Coordinate Y of the cell that is clicked.
el. Node of the DOM element that is a clicked cell.
realRowIndex. Global row index.
rowIndex. Row index.
To execute the example, the HTML page must contain the DataGrid named grid (see Example of Creating the DataGrid Component). Set the MouseUp event handler for table.
// Set the MouseUp event handler grid.MouseUp.add(function() { // Get table selection object var selection = grid.getSelection(); // Get object with initial coordinates of selection var startCoord = selection.getStartCoord(); // Output values of obtained object fields console.log("Name of the column that is clicked: " + startCoord.colIndex); console.log("Coordinate X of the cell that is clicked: " + startCoord.coordX); console.log("Coordinate Y of the cell that is clicked: " + startCoord.coordY); console.log("Global row index: " + startCoord.realRowIndex); console.log("Row index: " + startCoord.rowIndex); });
Click one of the table cells with the left mouse button. As a result, the row, which cell was clicked is selected:
The browser console displays information about the object with initial coordinates of selection:
Name of the column that is clicked: popul
Coordinate X of the cell that is clicked: 143
Coordinate Y of the cell that is clicked: 155
Global row index: 5
Row index: 5
The identical result may be obtained if the strings are replaced in the example:
// Get table selection object var selection = grid.getSelection(); // Get object with initial selection coordinates var startCoord = selection.getStartCoord();
with the following code:
// Get object with initial coordinates of selection by method of the PP.Ui.DataGrid class var startCoord = grid.getSelectedCoord();
See also: