Setting width of flexsheet columns at runtime

Posted by: db45600 on 28 February 2022, 6:57 pm EST

  • Posted 28 February 2022, 6:57 pm EST

    Hi,

    I have flexsheet with two columns and I need to set width of both columns at runtime. How can I do this. I tried setting at runtime but its not working. Kindly help.

    this.flexSheetIntro.columns.push(new wjcGrid.Column({

    header: ‘UnitID’,

    binding: ‘UnitID’,

    isReadOnly: false

    }));

    this.flexSheetIntro.columns.push(new wjcGrid.Column({

    binding: ‘Name’,

    header: ‘Name’,

    isReadOnly: false

    }));

  • Posted 1 March 2022, 8:09 am EST

    Hello,

    You may call the autoSizeColumns method of FlexGrid to adjust the width of all columns according to the content at once as per your requirement. And if you wish to adjust the width of specific columns then you can use the autoSizeColumn method and pass the index of that specific column to the method. Please refer to the API link below for reference:

    autoSizeColumns: https://www.grapecity.com/wijmo/api/classes/wijmo_grid.flexgrid.html#autosizecolumns

    autoSizeColumn: https://www.grapecity.com/wijmo/api/classes/wijmo_grid.flexgrid.html#autosizecolumn

    If you still face any issues then do let us know.

    Regards

  • Posted 8 March 2022, 4:36 pm EST

    Hello,

    I tried autoSizeColumns and autoSizeColumn both methods but its not working. Can you please provide some example to use these method. It will be more helpful.

    I tried this,

    this.flexSheetIntro.selectedSheet.grid.autoSizeColumns(0,1,true,600);

    Thanks

  • Posted 9 March 2022, 2:31 am EST

    Hello,

    The autoSizeColumns method is also available at FlexSheet control, you may call the autoSizeColumns directly for the FlexSheet columns. Please refer to the code snippet and sample link below demonstrating the same:

    
    boundSheet.autoSizeColumns(0,1,true,600);  //boundSheet is the instance of FlexSheet
    
    

    Sample link: https://jscodemine.grapecity.com/share/1Wl0Fd8hmE2DMccapofTlA/

    If the issue still persists, please share a sample replicating the issue so that we can investigate the issue at our end and assist you accordingly.

    Regards

Need extra support?

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

Learn More

Forum Channels