How to prevent column and row headers from being resizable

Posted by: adisa.craig on 10 June 2019, 12:05 pm EST

    • Post Options:
    • Link

    Posted 10 June 2019, 12:05 pm EST

    I have tired preventing the user from being able to resize the column and row headers using the below code but they are still able to

    
    activeSheet.getRange(-1, 0, -1, 1, GC.Spread.Sheets.SheetArea.rowHeader).resizable(false);
    activeSheet.getRange(0, -1, 1, -1, GC.Spread.Sheets.SheetArea.colHeader).resizable(false);
    activeSheet.setColumnResizable(-1, false, GC.Spread.Sheets.SheetArea.colHeader);
    activeSheet.setRowResizable(-1, false, GC.Spread.Sheets.SheetArea.rowHeader);
    
    

    Is this code incorrect?

  • Posted 11 June 2019, 3:09 am EST

    Hi Adisa,

    You need to pass the column/row index into setColumnResizable()/setRowResizable() method instead of -1. Please refer to the following code snippet:

    // turn off column resize for 4th column of view area
    sheet.setColumnResizable(3, false, GC.Spread.Sheets.SheetArea.viewPort);
    

    To resize using the getRange() method, please refer to the following code snippet:

    // turn off resize for 1st column of view area
    sheet.getRange(-1, 0, -1, 1, GC.Spread.Sheets.SheetArea.viewPort).resizable(false);
    
    // turn off resize for 1st row of view area
    sheet.getRange(0, -1, 1, -1, GC.Spread.Sheets.SheetArea.viewPort).resizable(false);
    

    Regards

  • Posted 11 June 2019, 9:51 am EST

    Hi Sharad,

    I am trying to prevent the column and row headers from resizing.

    If I want to turn off resize for the column header what would the code be?

    // turn off column resize for column header of view area

    sheet.setColumnResizable(??, false, GC.Spread.Sheets.SheetArea.viewPort);

  • Posted 12 June 2019, 2:21 am EST

    colHeader and viewport shares the same columns so we could disable the columns resizing for the colHeaders using the same code as for viewport i.e.

    sheet.setColumnResizable(colIndex, false, GC.Spread.Sheets.SheetArea.viewport);
    

    Similarly, rows resizing in the rowHeaders could be set like:

    sheet.setRowResizable(rowIndex, false, GC.Spread.Sheets.SheetArea.viewport);
    

    Please refer to the following code snippet for disabling row resizing in the columnHeaders and column resizing in the row headers:

    // disable row resizing in the column headers
    sheet.setRowResizable(0, false, GC.Spread.Sheets.SheetArea.colHeader);
    sheet.getRange(0, -1, 1, -1, GC.Spread.Sheets.SheetArea.colHeader).resizable(false);
    
    // disable col resizing in the row headers
    sheet.setColumnResizable(0, false, GC.Spread.Sheets.SheetArea.rowHeader);
    sheet.getRange(-1, 0, -1, 1, GC.Spread.Sheets.SheetArea.rowHeader).resizable(false);
    
  • Posted 12 June 2019, 2:25 pm EST

    Hi Sharad I have used the code provided in your last response, but the rowHeader and columnHeader are still resizable.

    
    // disable row resizing in the column headers
    sheet.setRowResizable(0, false, GC.Spread.Sheets.SheetArea.colHeader);
    sheet.getRange(0, -1, 1, -1, GC.Spread.Sheets.SheetArea.colHeader).resizable(false);
    
    // disable col resizing in the row headers
    sheet.setColumnResizable(0, false, GC.Spread.Sheets.SheetArea.rowHeader);
    sheet.getRange(-1, 0, -1, 1, GC.Spread.Sheets.SheetArea.rowHeader).resizable(false);
    
  • Posted 13 June 2019, 4:42 am EST

    Hi Adisa,

    The code snippet demonstrates how we could disable resizing for a particular column/row. Please refer to the following code snippet to disable resizing for all rows/column:

    sheet.getRange(-1, 0, -1, sheet.getColumnCount(GC.Spread.Sheets.SheetArea.rowHeader), GC.Spread.Sheets.SheetArea.rowHeader).resizable(false);
    sheet.getRange(0, -1, sheet.getRowCount(GC.Spread.Sheets.SheetArea.colHeader), -1, GC.Spread.Sheets.SheetArea.colHeader).resizable(false);
    

    You may also refer to the attached sample demonstrating the same.

    spreadSample2.zip

Need extra support?

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

Learn More

Forum Channels