Custom Top Left - Select All - Flexsheet button

Posted by: curiosichi on 6 August 2019, 1:43 pm EST

    • Post Options:
    • Link

    Posted 6 August 2019, 1:43 pm EST - Updated 3 October 2022, 7:46 pm EST

    I have a flexsheet where I needed to hide the default column headers and row headers, but still want a top left “Select All”

    How can I turn the top left corner of every page of my flexsheet workbook into a button to select all without default headers?

    I tried an itemformatter and a SelectionChanging handler but I kept getting recursive calls as the selection was reselecting the top left cell again when calling:

    
    this.ServerWorkbook.select(new CellRange(0, 0, this.ServerWorkbook.rows.length, this.ServerWorkbook.columns.length), false);
    
    

    Is there a better way to select all then the way I did it as well?

  • Posted 7 August 2019, 12:38 am EST

    Hi,

    You may need to handle the mousedown event of FlexSheet. In the event handler, using the hitTest method, we can get the current row and column. If the current cell is a top left cell (in your case, the cell is [0, 0]), then use the select method of FlexSheet and select all the cells. Please refer to the code snippet and the sample below:

    flexSheet.hostElement.addEventListener('mousedown', e => {
          var hti = flexSheet.hitTest(e);
          var rng;
          if(hti.row == 0 && hti.col == 0) {
            rng = new wjcGrid.CellRange(0, 0, flexSheet.rows.length, flexSheet.columns.length);
            flexSheet.select(rng);
          }
        })
    

    https://stackblitz.com/edit/angular-tcuwqk

    Regards,

    Ashwin

Need extra support?

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

Learn More

Forum Channels