ParamQuery grid support forum

General Category => ParamQuery Pro Evaluation Support => Topic started by: akraines on July 25, 2019, 09:02:14 pm

Title: Customize Autofit function
Post by: akraines on July 25, 2019, 09:02:14 pm
Is it possible to customise the implementation of the Autofit option?

I'd like to make the autofit function take into account column header and data width to determine an optimal the width of the columns.
Title: Re: Customize Autofit function
Post by: paramvir on July 26, 2019, 10:17:50 am
Autofit logic can't be customized and it doesn't need to because it already considers the cell widths in table body and header.

It can be configured with flex option https://paramquery.com/pro/api#option-flex
Title: Re: Customize Autofit function
Post by: akraines on July 29, 2019, 06:24:57 pm
Perfect!
Thanks
Title: Re: Customize Autofit function
Post by: akraines on July 29, 2019, 07:03:40 pm
The flex option works very well except that it seems to put all the remaining space in the last column. Am I doing something wrong?
height:"500",
width:"100%",
colModel,
                scrollModel: { autoFit: true },
                groupModel,
                groupOption: function( event, {ui, oldGM, source} ) {
                    const groupModel = this.option("groupModel");                   
                    toggleGroupColumnsVisible( groupModel.dataIndx);                 
                },
flex: { on: true },



        function toggleGroupColumnsVisible(groupColumns) {
            const showGroupColumn = _.isArray(groupColumns) ? groupColumns.length > 0 : groupColumns;
            colModel = showGroupColumn ? [groupColumn, ...colModelFromServer] : colModelFromServer;
            if (_.isArray(groupColumns)){
                const columnsToHide = new Set(groupColumns);
                _.map(colModel, c => c.hidden = columnsToHide.has(c.dataIndx))
            }
            pqGridInstance.option( "colModel", colModel );
            pqGridInstance.refreshView(colModel);   
            pqGridInstance.flex();
        }
Title: Re: Customize Autofit function
Post by: paramvir on July 29, 2019, 07:41:53 pm
It's because of scrollModel: { autoFit: true }

you may need to comment/ remove it.
Title: Re: Customize Autofit function
Post by: akraines on July 29, 2019, 08:08:09 pm
But then it doesn't take 100% width. I'd like it to share the remaining space between all the columns. The truth is that I'd prefer to have autofit false since it makes coulummn resizing work unnaturaly - is there a way to make it use 100% space when flex is true without using autofit.

Thanks.