Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: force "autofit all columns"  (Read 8502 times)
Jos? V.
Posts: 58


« on: January 09, 2023, 05:29:57 pm »

Hi guys,

Is there any way to force "Autofit all columns" every time a table is open?

I know GDC and GBC save the previous settings and keep table column sizes but we are having an issue with a client which company policy forces chrome to delete application saved settings.

Is there any other way to achieve this behaviour?
Thank you

Reuben B.
Four Js
Posts: 1116


« Reply #1 on: January 10, 2023, 11:39:33 pm »

If you search on AutoFit on your GBC project sources, you will find references to AutoFit  in $GBC_PROJECT_DIR/src/js/base/widget/widgets/containers/responsive/RTableWidget.js and in particular a function autoFitAllColumns

With another customer with a similar request I investigated having a custom front-call (http://4js.com/online_documentation/fjs-gbc-manual-html/#gbc-topics/c_gbc_frontcalls.html) calling that same function. 

What we found was that we could add a 4gl button that would call that same functionality via the custom front-call.  The customer ended up using this technique to add a button to Auto-Fit all the tables on a form with a single click rather than the user having to click in each table individually. 

We tried calling this custom front-call in the BEFORE DISPLAY to do what you want, that is to autofit the table as it is loaded.

BEFORE DISPLAY
   CALL custom front-call to trigger autofit

but what we found was that when being called at that point, the table had not been populated so there was no data to do the auto fit calculations! We could verify that hypothesis with something like ...

ON TIMER 1
   IF first_time THEN
      CALL custom front-call to trigger autofit
      LET first_time = FALSE
   END IF

and this would autofit the columns automatically as the data had been populated by the time the ON TIMER was triggered.  However You don't want ON TIMER 1 in your code so this is not a viable solution.  (In writing this I can't recall if we tried in BEFORE ROW)

There is an open enhancement in the system https://4js.com/support/issue/?id=GBC-2345 to provide programmatic control of autoFitAllColumns, and fitToViewAllColumns.  You could get your support contact to add you to the list of requestors to that.

There has also been consideration to move the storage of stored settings away from the client to the server., but that would be a major release enhancement if and that is a big if, if we went down that path, a lot of unanswered questions.  (https://4js.com/support/issue/?id=FGL-4536).  Again get your support contact to add you to requesters for that enhancement if interested.

For your problem where the stored settings have been removed due to company policy, my thought is to investigate writing a custom front-call to read/write all or individual stored settings.  At application end or press of a button read them and write them in your database, and at application start read them from a database and write to where the GBC stores them.  With GDC in the past I used a front-call calling regedit to do something similar before UAC got in the way.  So I would start by looking at GBC project sources, search on stored settings, note on how it is implemented, can I write a custom front-call to read/write that information? and store it elsewhere?

Reuben








Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Jos? V.
Posts: 58


« Reply #2 on: January 11, 2023, 10:14:10 am »

Thank you Reuben!

These are two very interesting approaches to this issue and will come in very handy!
Both might solve the problem so we're going to study your sugestion and choose a path.

We are also going to subscribe GBC-2345 and FGL-4536 since they look as good candidates for new useful funcionality.

Again, thank you!
Susobh S.
Posts: 22


« Reply #3 on: January 13, 2023, 01:38:04 pm »

Hi

Just to give another solution based on GBC Customization, which would not need to touch 4gl side, and without any button click.

Idea is to Customize the existing RTable widget and override the setVisibleRows function and try implement the autofit function.
Using this, autofit will be done for each of the Table in the screen.

Below is a sample.
Note : I haven't tested it fully, but basically must do the job.



/// FOURJS_START_COPYRIGHT(D,2019)
/// Property of Four Js*
/// (c) Copyright Four Js 2019, 2021. All Rights Reserved.
/// * Trademark of Four Js Development Tools Europe Ltd
///   in the United States and elsewhere
///
/// This file can be modified by licensees according to the
/// product manual.
/// FOURJS_END_COPYRIGHT
"use strict";

modulum('MyRTableWidget', ['TableWidget'],
    function(context, cls) {

        /**
         * Responsive table widget.
         * @class MyRTableWidget
         * @memberOf classes
         * @extends classes.TableWidgetBase
         * @publicdoc
         */
        cls.MyRTableWidget = context.oo.Class(cls.RTableWidget, function($super) {
            return /** @lends classes.MyRTableWidget.prototype */ {
                __name: "MyRTableWidget",
                __templateName: "RTableWidget",
                __fitDone: false,

                setVisibleRows: function(visibleRows) {
                    $super.setVisibleRows.call(this, visibleRows);

                    if (!this.__fitDone) {
                        let columns = this.getColumns();
                        let totalAvail = this.getDataAreaWidth();
                        let totalCurrent = 0;
                        let tc = null,
                            i = 0;
                        for (i = 0; i < columns.length; i++) {
                            tc = columns;
                            if (!tc.isHidden()) {
                                if (tc.isSizable()) {
                                    totalCurrent = totalCurrent + tc.getWidth();
                                } else {
                                    totalAvail = totalAvail - tc.getWidth();
                                }

                            }
                        }
                        if (totalCurrent > 0 && totalAvail) {
                            this.__fitDone = true;
                            this.fitToViewAllColumns();
                        }
                    }
                },


            };
        });
        cls.WidgetFactory.registerBuilder("RTable", cls.MyRTableWidget);
        cls.WidgetFactory.registerBuilder("Table[tableType=responsive]", cls.MyRTableWidget);
    });

Thanks And Regards
Susobh Sugathan
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines