Spread V11: Need handler on clicking celltext

Posted by: tkarthik.006 on 5 July 2018, 6:34 pm EST

    • Post Options:
    • Link

    Posted 5 July 2018, 6:34 pm EST

    Hi,

    I need a handler on clicking cell text or any certain portion of the cell so that I can do some additional actions based on it.

    Currently I’m using cellclick which makes the selection of cell impossible without triggering cellclick which in return executes my funtionality.

    Please provide a solution for this.

    Thanks.

  • Posted 5 July 2018, 9:13 pm EST

    Hello Karthik,

    You can use the EditStarting event, which will only fire when the user will start editing the cell.

    
    var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"),{sheetCount:3});
    var activeSheet = spread.getActiveSheet();
    
    activeSheet.bind(GC.Spread.Sheets.Events.EditStarting, function (sender, args) {  
        console.log("Start cell editing.");
    });
    
    

    Thanks,

    Deepak Sharma

  • Posted 8 July 2018, 1:00 am EST

    Hi,

    My spreadsheet is a read only one, So there is no possibility of using that event.

    I’m trying to replicate the below example in my case :

    https://www.grapecity.com/en/demos/spread/JS/TutorialSample/#/demos/outlineColumn

    My challenge is to show an icon which will expand the rows as the same as the above example.

    But in my case the children rows or the sub rows are not present as we are rendering them on cell click action conditionally.

    Trying the above example requires the rows to be presented on client side but my data will not be rendered until a specific action, for example an outline column is expanded.

    So in a nutshell, I need an custom icon to be present in selected cells, which will give me a callback on clicking on that icon specifically as mentioned in the above outlinecolumn example so that I can include some rendering manipulations in sheet.

    P.S.: The callback for the icon should not be a part of cell events such as cellclick, selectionchanged, selectionchanging etc. It should only depend on that icon in the cell. The formatting and behavior is identical to that of outline column example with some custom conditions as mentioned above.

    Please respond as soon as possible.

    Thanks.

  • Posted 9 July 2018, 11:05 pm EST

    Hello,

    If you do not want to use the cellclick event, you can work with spread’s click event and check if a cell is clicked with HitTest.

    You can get the cell index on mouse click using the code as follows:

    
    var spread = new GC.Spread.Sheets.Workbook($("#ss")[0]);
    var activeSheet = spread.getActiveSheet();
    activeSheet.setRowCount(4, GC.Spread.Sheets.SheetArea.colHeader);
    $("#ss").click(function (e) {
        // Acquire cell index from the mouse-clicked point of column header cells.
        var offset = $("#ss").offset();
        var x = e.pageX - offset.left;
        var y = e.pageY - offset.top;
        var target = spread.getActiveSheet().hitTest(x, y);
    
        if(target &&
                target.rowViewportIndex === -1 &&
                (target.colViewportIndex === 0 || target.colViewportIndex === 1)){
            console.log("Row index of mouse-clicked column header cells: " + target.row);
            console.log("Column index of mouse-clicked column header cells: " + target.col);
        }
    });
    
    

    Thanks,

    Deepak Sharma

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels