Setting data column width in a Transposed grid

Posted by: jt on 19 June 2023, 8:42 pm EST

    • Post Options:
    • Link

    Posted 19 June 2023, 8:42 pm EST

    Is there a way to set the width of data columns in a transposed grid?

    How would you set the width of the columns “Constant growth”, “Optimus prime” etc, in this example?: https://www.grapecity.com/wijmo/demos/Grid/TransposedGrid/RowGroups/angular

  • Posted 20 June 2023, 8:41 pm EST

    Hi,

    To set the column width in TransposedGrid, you can handle the ‘loadedRows’ event of the grid and set it manually like this -

    loadedRows(s: any, e: any) {
            // set default size for all columns
            s.columns.defaultSize = 200;
    
            // set width of specific column in grid
            s.columns[0].width = 350;
        }

    You can refer to the following sample for the same - https://jscodemine.grapecity.com/share/cH-LC0QV3E6zmObOrhVHuA

    In case, you face any issues, please let us know.

    Regards,

    Vivek Pannu

  • Posted 20 June 2023, 9:24 pm EST - Updated 20 June 2023, 11:31 pm EST

    Thanks! It works apart from one little thing:

    Apparently the first column and the first data column (marked with red arrows) is both at index 0. So when I set s.column[0].width both of them change. But I only want to set the width of the data column.

    How can I tell them appart?

    UPDATE UPDATE UPDATE:

    I figured it out :smiley:

    First set the default width of all the columns. This will also change the first column, but it can be overwritten by setting width for rowHeader column

    [code]loadedRows(grid:wjcGrid.FlexGrid,e:Event) {
    	grid.columns.defaultSize = 60; 
    	grid.rowHeaders.columns[0].width = 90; 
    }[/code]
    

    Maybe there is a cleaner solution, but this works.

  • Posted 21 June 2023, 3:47 pm EST

    Hi,

    We are glad that you solved the issue on your own. Your approach to setting the rowHeaders column width through the rowHeaders panel of the flexGrid is correct and it will work as expected.

    In case, you have any further questions, please let us know.

    Regards

Need extra support?

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

Learn More

Forum Channels