Dynamic Row Colour Change when a field is changed

Toddy_BoyToddy_Boy Member Posts: 231
Has anyone managed to change the colour on a repeater row when a field on that row is amended? e.g. I want to change the StyleText of the fields from Attention to Standard (and reversed) based on an option field value which can be edited on the row.
Life is for enjoying ... if you find yourself frowning you're doing something wrong

Comments

  • JDVyskaJDVyska Member Posts: 179
    OBJECT Table 50000 Style Test
    {
      OBJECT-PROPERTIES
      {
        Date=15-10-28;
        Time=12:10:51;
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
      }
      FIELDS
      {
        { 1   ;   ;Code                ;Code20         }
        { 10  ;   ;Description         ;Text30         }
        { 20  ;   ;StyleText           ;Text30         }
      }
      KEYS
      {
        {    ;Code                                    ;Clustered=Yes }
      }
      FIELDGROUPS
      {
      }
      CODE
      {
    
        BEGIN
        END.
      }
    }
    
    OBJECT Page 50000 Style Test
    {
      OBJECT-PROPERTIES
      {
        Date=15-10-28;
        Time=12:14:49;
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        SourceTable=Table50000;
        PageType=List;
        OnAfterGetRecord=BEGIN
                           SetLineStyle();
                         END;
    
        OnNewRecord=BEGIN
                      LineStyle := 'Standard';
                    END;
    
      }
      CONTROLS
      {
        { 1220060002;0;Container;
                    ContainerType=ContentArea }
    
        { 1220060003;1;Group  ;
                    Name=Group;
                    GroupType=Repeater }
    
        { 1220060004;2;Field  ;
                    SourceExpr=Code;
                    StyleExpr=LineStyle }
    
        { 1220060005;2;Field  ;
                    SourceExpr=Description;
                    StyleExpr=LineStyle }
    
        { 1220060006;2;Field  ;
                    SourceExpr=StyleText;
                    OnValidate=BEGIN
                                 SetLineStyle();
                               END;
                                }
    
      }
      CODE
      {
        VAR
          LineStyle@1220060002 : Text;
    
        LOCAL PROCEDURE SetLineStyle@1220060003();
        BEGIN
          CASE StyleText OF
            'Favorable': LineStyle := 'Favorable';
            'Unfavorable': LineStyle := 'Unfavorable';
            ELSE
              LineStyle := 'Standard';
          END;
        END;
    
        BEGIN
        END.
      }
    }
    
    
    
    JEREMY VYSKA
    CEO, Spare Brained Ideas, Göteborg, Sweden
    New (April 2021) Getting Started with Microsoft Dynamics 365 Business Central Book Available: "Your First 20 Hours with Business Central"
  • Toddy_BoyToddy_Boy Member Posts: 231
    That's the solution I came to however it didn't work.

    I've done some further investigation, I'm trying to get this working on the Sales Order Subform (46), when the option field is changed the style is changed correctly, but when I move off the line the style reverts to it's previous style. Maybe something to do with a refresh?
    Life is for enjoying ... if you find yourself frowning you're doing something wrong
  • Wisa123Wisa123 Member Posts: 308
    Hi,

    Cant try it right now but try:
    * Moving your Code into the onAfterGetCurrRecord Trigger,
    if that doesnt work
    * Return your LineStyle from your function, and call the function directly in the StyleExpr attr.

    Regards Wisa
    Austrian NAV/BC Dev
  • Toddy_BoyToddy_Boy Member Posts: 231
    No joy sadly, I get an Unknown function type error
    Life is for enjoying ... if you find yourself frowning you're doing something wrong
  • Toddy_BoyToddy_Boy Member Posts: 231
    Further playing about, the above by JDVyska works if the RefreshOnActivate set to Yes, however it doesn't for my Sales Order Lines subpage issue.
    Life is for enjoying ... if you find yourself frowning you're doing something wrong
  • Toddy_BoyToddy_Boy Member Posts: 231
    edited 2015-10-30
    Got there, if the OnValidate trigger looks like the statements below then it works. :)
    CurrPage.SAVERECORD;
    CurrPage.UPDATE(FALSE);
    SetTextStyle;
    

    However, when i now try the same approach on a different page I can get the other fields in the repeater to change colour but not the option field I'm amending. :s
    Life is for enjoying ... if you find yourself frowning you're doing something wrong
Sign In or Register to comment.