Options

Form.TableBox.TextBox.VISIBLE property is not updated

DeSpDeSp Member Posts: 105
Let's assume that there is a Form with a TableBox having several TextBoxes. When a user, running this Form, hides a column, its VISIBLE property remains the same as before - it is not updated in C\SIDE. So if you try to place some code within this Form to check its controls visibility:
MESSAGE(FORMAT(CurrForm.Control.VISIBLE));
For some reason the property value in this case will be the same as before user changed it by hiding the column. The only known way for me is to reopen this Form - then all the properties get their updated values. But this way is not suitable for current task wich is to show appropriate columns during exporting to Excel according to their visibility.

Any suggestions, ideas, useful information would be very much appreciated.

Thank you in advance.
Nil desperandum

Comments

  • Options
    FommoFommo Member Posts: 138
    When the user hide a certain column or changes the width it is stored in the zup-file so that the certain user get the same thing next time he shows the table.

    I don't know of any API to check the zup file to get this information though, that would be really nice.
  • Options
    MTCMTC Member Posts: 159
    Navision does not save anything to the ZUP until the application is closed. Therefore it stores this type of thing in memory or in some unknown virtual table, however I do not have a clue where this may be.

    This is not possible to solve with a combination of triggers, it's really annoying, similar to no trigger generated by clicking on a tab (that is however possible to workaround).

    All I can think of is that you modally run your form from another object (codeunit or invisible form) giving it (the form with the tablebox) a function to check from the object that runs it to find out whether the user canceled/closed the window or clicked on your button (or whatever) to export (both would close the window - you button or whatever setting the variable the function would return and then doing a CurrForm.CLOSE). This would then be checked from the object that opened the form and if the user selected to export, the object that run the form clear the form variable, call another new function to say en export is in progress (the variable this sets would be checked in OnOpenForm) and then modally run the form again. Now the property would be updated and OnOpenForm could perform the export if the variable was set to true.

    Madness I know, but it would work, and I cannot think of another way to do it.
  • Options
    MTCMTC Member Posts: 159
    Something along these lines:
    OBJECT Table 70000 TestTable
    {
      OBJECT-PROPERTIES
      {
        Date=13/04/07;
        Time=21:41:19;
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
      }
      FIELDS
      {
        { 1   ;   ;F1                  ;Integer        }
        { 2   ;   ;F2                  ;Integer        }
      }
      KEYS
      {
        {    ;F1                                       }
      }
      CODE
      {
    
        BEGIN
        END.
      }
    }
    
    OBJECT Form 70000 Tester
    {
      OBJECT-PROPERTIES
      {
        Date=13/04/07;
        Time=21:49:40;
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        Width=9900;
        Height=6820;
        TableBoxID=1000000000;
        SourceTable=Table70000;
        OnOpenForm=BEGIN
                     IF EXPORTON THEN BEGIN
                         MESSAGE('Exporting');
                         MESSAGE('F1 VISIBLE IS: ' + FORMAT(CurrForm.F1.VISIBLE));
                         MESSAGE('F2 VISIBLE IS: ' + FORMAT(CurrForm.F2.VISIBLE));
                         MESSAGE('Done Exporting');
                     END
                     ELSE MESSAGE('Not Exporting');
                   END;
    
      }
      CONTROLS
      {
        { 1000000311;CommandButton;2640;5940;2200;550;
                                                     HorzGlue=Right;
                                                     VertGlue=Bottom;
                                                     Default=Yes;
                                                     PushAction=LookupOK;
                                                     InvalidActionAppearance=Hide }
        { 1000000312;CommandButton;5060;5940;2200;550;
                                                     HorzGlue=Right;
                                                     VertGlue=Bottom;
                                                     Cancel=Yes;
                                                     PushAction=LookupCancel;
                                                     InvalidActionAppearance=Hide }
        { 1000000313;CommandButton;7480;5940;2200;550;
                                                     HorzGlue=Right;
                                                     VertGlue=Bottom;
                                                     PushAction=FormHelp }
        { 1000000314;CommandButton;220;5940;2200;550;Name=Export;
                                                     OnPush=BEGIN
                                                              EXPORTON := TRUE;
                                                              CurrForm.CLOSE;
                                                            END;
                                                             }
        { 1000000000;TableBox;220 ;220  ;9350 ;5500  }
        { 1000000003;TextBox;423  ;2640 ;1700 ;440  ;HorzGlue=Left;
                                                     ParentControl=1000000000;
                                                     InColumn=Yes;
                                                     SourceExpr=F1 }
        { 1000000004;Label  ;0    ;0    ;0    ;0    ;ParentControl=1000000003;
                                                     InColumnHeading=Yes }
        { 1000000005;TextBox;2381 ;2530 ;1700 ;440  ;HorzGlue=Left;
                                                     ParentControl=1000000000;
                                                     InColumn=Yes;
                                                     SourceExpr=F2 }
        { 1000000006;Label  ;0    ;0    ;0    ;0    ;ParentControl=1000000005;
                                                     InColumnHeading=Yes }
      }
      CODE
      {
        VAR
          EXPORTON@1000000000 : Boolean;
    
        PROCEDURE IsExport@1000000000() : Boolean;
        BEGIN
          EXIT(EXPORTON);
        END;
    
        PROCEDURE SetExport@1000000001();
        BEGIN
          EXPORTON := TRUE;
        END;
    
        BEGIN
        END.
      }
    }
    
    OBJECT Form 70001 T2
    {
      OBJECT-PROPERTIES
      {
        Date=13/04/07;
        Time=21:46:20;
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        Width=8000;
        Height=8000;
        OnOpenForm=BEGIN
                     Frm.RUNMODAL;
                     IF Frm.IsExport THEN BEGIN
                         CLEAR(Frm);
                         Frm.SetExport;
                         Frm.RUNMODAL;
                     END;
    
                     CurrForm.CLOSE;
                   END;
    
      }
      CONTROLS
      {
      }
      CODE
      {
        VAR
          Frm@1000000000 : Form 70000;
    
        BEGIN
        END.
      }
    }
    

    Run T2.
  • Options
    DeSpDeSp Member Posts: 105
    Thanks, MTC, your solution works.
    Nil desperandum
Sign In or Register to comment.