How to / Best way to duplicate / deep copy individual flexsheet

Posted by: curiosichi on 7 June 2019, 10:54 am EST

  • Posted 7 June 2019, 10:54 am EST

    I need to deep copy (or duplicate) an individual flexsheet for grid manipulation without affected my angular website view of it. I am printing a PDF of my flexsheet workbook and need to alter the grid before I output it (special formatting, removing columns/rows). At the moment doing that with the reference to the displayed angular flexsheet grid means the view changes there instead of to just my PDF version.

    Doing this to a via the following is still altering the main grid via typescripts pass by reference:

    this.flexsheet.sheets.find(x => x.SheetOid === sheetOid).grid;
    

    I have tried several different approaches, and am now hoping there is something built into wijmo to handle this.

    
    // const desiredSheetGrid = this.flexsheet.sheets.find(x => x.SheetOid === sheetOid).grid;
            // const desiredSheetGrid = JSON.parse(JSON.stringify(this.flexsheet.sheets.find(x => x.SheetOid === sheetOid).grid));
            // const desiredSheetGrid = Object.assign({}, this.flexsheet.sheets.find(x => x.SheetOid === sheetOid).grid);
            // const desiredSheetGrid = [...this.flexsheet.sheets.find(x => x.SheetOid === sheetOid).grid];
            // const desiredSheetGrid = this.deepCopy(this.flexsheet.sheets.find(x => x.SheetOid === sheetOid).grid);
    
    

    Is there a suggested way to duplicate a sheet in typescript?

  • Posted 10 June 2019, 7:34 pm EST

    Hello,

    We are sorry but you cannot deep copy a flexgrid to another grid. But, you may create another grid using the same itemsSource of the original flexgrid and then apply any other changes to it. Also, to apply formatting to the grid, you may use the formatItem event of FlexGridPdfConverter class. Please refer to the sample below:

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

    API reference:

    formatItem: https://www.grapecity.com/wijmo/api/interfaces/wijmo_grid_pdf.iflexgridexportsettings.html#formatitem

    PdfFormatItemEventArgs: https://www.grapecity.com/wijmo/api/classes/wijmo_grid_pdf.pdfformatitemeventargs.html#style

Need extra support?

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

Learn More

Forum Channels