SpreadJS 13
GC.Spread.Sheets Namespace / Worksheet type / hitTest Method
The x-coordinate.
The y-coordinate.
In This Topic
    hitTest Method
    In This Topic
    Performs a hit test.
    Syntax
    var instance = new GC.Spread.Sheets.Worksheet(name);
    var value; // Type: Object
    value = instance.hitTest(x, y);
    function hitTest( 
       x : number,
       y : number
    ) : Object;

    Parameters

    x
    The x-coordinate.
    y
    The y-coordinate.

    Return Value

    See Remarks for a list of possible return values and their descriptions.
    Example
    This example uses the hitTest method.
    $("#ss").click(function (e) {
        //Acquire cell index from mouse-clicked point of regular cells which are neither fixed rows/columns nor row/column headers.
        var offset = $("#ss").offset();
        var x = e.pageX - offset.left;
        var y = e.pageY - offset.top;
        var target = activeSheet.hitTest(x, y);
    
        if (target &&
            (target.rowViewportIndex === 0 || target.rowViewportIndex === 1) &&
            (target.colViewportIndex === 0 || target.colViewportIndex === 1)) {
            alert("Row index of mouse-clicked cells: " + target.row + "\n" + "Column index of mouse-clicked cells: " + target.col);
        }
    });
    Remarks

    This method can return the following values:

    obj.x number type The x-coordinate that equals x param.
    obj.y number type The y-coordinate that equals y param.
    obj.rowViewportIndex number type The index of row viewport, -1 represents column header area, 0 represents frozen row area, 1 represents viewport area, 2 represents trailing frozen row area.
    obj.colViewportIndex number type The index of column viewport, -1 represents row header area, 0 represents frozen column area, 1 represents viewport area, 2 represents trailing frozen column area.
    obj.row number type The row index that point(x,y) is in.
    obj.col number type The column index that point(x,y) is in.
    obj.hitTestType GC.Spread.Sheets.SheetArea type The sheet area that point(x,y) is in.
    obj.resizeInfo object type The resize information.
    obj.resizeInfo.action string type "sizeRow" represents resizing row, "sizeCol" represents resizing column.
    obj.resizeInfo.index number type The index of row or column to resize.
    obj.resizeInfo.sheetArea GC.Spread.Sheets.SheetArea type The sheet area that the resized row or column is in.
    obj.groupHitInfo object type The group information.
    obj.groupHitInfo.what string type "rgh" represents row group header button, "cgh" represents column group header button, "rg" represents row group button, "cg" represents column group button, "empty" represents no button.
    obj.groupHitInfo.info object type The group button information.
    obj.groupHitInfo.info.index number type The range group summary index.
    obj.groupHitInfo.info.isExpanded boolean type Whether the range group is expanded.
    obj.groupHitInfo.info.level number type The range group level.
    obj.groupHitInfo.info.lineDirection GC.Spread.Sheets.RangeGroupDirection type The range group direction.
    obj.groupHitInfo.info.paintLine boolean type Whether to paint the line of the range group.
    obj.filterButtonHitInfo object type The filter button information.
    obj.filterButtonHitInfo.row number type The row index that the filter button is in.
    obj.filterButtonHitInfo.col number type The column index that the filter button is in.
    obj.filterButtonHitInfo.x number type The x-coordinate of the filter button.
    obj.filterButtonHitInfo.y number type The y-coordinate of the filter button.
    obj.filterButtonHitInfo.width number type The width of the filter button.
    obj.filterButtonHitInfo.height number type The height of the filter button.
    obj.filterButtonHitInfo.sheetArea GC.Spread.Sheets.SheetArea type The sheet area that the filter button is in.
    obj.dragInfo object type The drag information.
    obj.dragInfo.action string type "drag" represents drag drop or drag fill.
    obj.dragInfo.side string type "left","right","top", and "bottom" represent drag drop, "corner" represents drag fill.
    obj.dragInfo.outside boolean type Whether the operation is out of the active selection range.
    obj.cellTypeHitInfo object type The cell type information.
    obj.cellTypeHitInfo.x number type The x-coordinate that equals the x param.
    obj.cellTypeHitInfo.y number type The y-coordinate that equals the y param.
    obj.cellTypeHitInfo.row number type The row index of the cell.
    obj.cellTypeHitInfo.col number type The column index of the cell.
    obj.cellTypeHitInfo.cellRect GC.Spread.Sheets.Rect type The rectangle of the cell.
    obj.cellTypeHitInfo.sheetArea GC.Spread.Sheets.SheetArea type The sheet area of the cell.
    obj.cellTypeHitInfo.isReservedLocation boolean type Whether point(x,y) is in special area that the cell type needs to handle.
    See Also

    Reference

    Worksheet type