Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
620
HierarchicalGrid Width 100% Autosize all columns shows horizontal scrollbar
posted

I'm using the igHierarchicalGrid. I'm creating it like this:

$grid.igHierarchicalGrid({
            width: "100%",
            dataSource: data,
            dataSourceType: "json",
            responseDataKey: "Data",
            autoGenerateColumns: false,
            columns: colsArray,
            defaultColumnWidth: "*",
            autoGenerateLayouts: false,
            columnLayouts: layoutsArray,
            features: [
                        { name: "MultiColumnHeaders" },
                        {
                                    name: "Sorting",
                                    type: "local",
                                    mode: "multi",
                                    persist: true
                        },
                        {
                                    name: "Filtering",
                                    type: "local",
                                    persist: true
                        }
            ]
        });

I don't have width defined in any of the columns and I also have defaultColumnWidth: "*" in every layout. However the main grid (the most outer one) generates an horizontal scrollbar.

I've checked and the divs #grilla_table_container and #grilla_table_scroll are created ok but the table inside has width property set with 30 extra pixels. I think it has to do with the default value of expandColWidth. If I set that property with a value of 0, no scrollbar is shown but of course, the expand column dissapears.

How can I avoid the horizontal scrollbar?

Thanks!

Parents
No Data
Reply
  • 200
    Offline posted

    Hello Hugo,

    Thank you for contacting Infragistics.

    The scrollbar appears because the autofitLastColumn option is set to true by default. This option overrides the default width of the last column.

    Additionally when setting defaultColumnWidth to '*' if the columns exceed the 100% width you will again have a horizontal scrollbar since ‘*’ sets the width of the column to wrap its content.

    I would suggest setting the defaultColumnWidth to:

    100 devised by the visible columns count in pixels.

    For example if you have 2 visible columns the defaultColumnWidth should be ‘50%’ (100 / 2). If 4 the defaultColumnWidth would be ‘25%’.

    const visibleColumnsCount = colsArray.filter(c => c.hidden !== true).length;
    const defaultColumnWidth = (100 / visibleColumnsCount) + '%';

    I have attached a sample representing how this would work having two columns in the parent grid.

    In case you have additional questions feel free to ask them.

    1346.WidthsHierarchicalGridSample.zip

Children