SpreadJS 14
Features / Cells / Edit Mode Always
In This Topic
    Edit Mode Always
    In This Topic

    You can set the cell to always be in edit mode when the user clicks on it.  Normally the user types or double-clicks before the cell goes into edit mode.

    Set the startEdit method in the EnterCell event to cause the cell to go into edit mode as soon as the user clicks on or uses tab or enter to move to the cell.

    If the selectAll parameter in the startEdit method is set to true, then it selects all the text when the text is changed during editing.

    Using Code

    This example puts the cell in edit mode when the user clicks on it.

    JavaScript
    Copy Code
    window.onload = function()
    {
       var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"),{sheetCount:3});
       var activeSheet = spread.getActiveSheet();
      // Set to be always in input mode.
       spread.bind(GC.Spread.Sheets.Events.EnterCell, function (event, data)
      {
         var sheet = data.sheet;
         activeSheet.startEdit(false);
       });
     }
    

    This example selects the text when editing starts.

    Example Title
    Copy Code
    $(document).ready(function ()
    {
        new GC.Spread.Sheets.Workbook(document.getElementById("ss"),{sheetCount:3});
        var sheet = spread.getActiveSheet();
        sheet.setValue(0, 0, "ABC", GC.Spread.Sheets.SheetArea.viewport);
       
        // Set it to be always in input mode.
          spread.bind(GC.Spread.Sheets.Events.EnterCell, function (event, data)
         {
            var activeSheet = data.sheet;
            activeSheet.startEdit(true);
         });
    });