9 Replies Latest reply on Mar 26, 2015 9:22 AM by justinc

    Conditional formatting of selected value list item

    davehob

      I have a value list, made up of id field and text field, show values only from second field:

      vl_PTY.jpg

      Is there a way of applying conditional formatting to the selected item?  (The reason I need this is that, although the value list automatically stretches to the width of the longest item, the selected value may not fit in the field, so I need to apply cf based on the length of the item.) 

       

      Thanks,

      Dave.

        • 1. Re: Conditional formatting of selected value list item
          rrrichie

          You mean that the value originally selected is truncated and saved into the field?

           

          In the normal value list, FileMaker highlights the current value.  So you could reverse the value to its full length when the user enters the field.  (You can do this with an object enter script trigger en use a  LET (table::fieldname= fulllength (xxx) ; "" ) as the script Parameter.

          • 2. Re: Conditional formatting of selected value list item
            davehob

            Richie - Thanks for this, although I'm afraid I don't fully understand your suggestion. As you say, the problem is that when the user selects an item that it longer than the available space, only part of it is displayed after selection.  That's why I want to apply conditional formatting, to reduce the size of the font if the length of the item demands it.  But when specifying the formatting, I don't know what field to specify - the field itself is a (global) key field, whereas it's the displayed value that's too long. 

            • 3. Re: Conditional formatting of selected value list item
              Mike_Mitchell

              Can you use the length of the related field? PTY::type?

              • 4. Re: Conditional formatting of selected value list item
                davehob

                Mike - thanks, and yes, that will do it.  (The reason I thought it wouldn't is because it didn't, but having done a quick test in a simplified solution, it works fine.  So I think I must have a relationship problem - the conditional formatting calc is just not seeing the correct value, so that's an altogether different problem, which I now need to resolve.)

                 

                Thanks for pointing me in the right direction.

                 

                Dave.

                • 5. Re: Conditional formatting of selected value list item
                  justinc

                  Dave,

                     You mentioned that the field was a global, which confused me a bit.  Is this a single-record (i.e. Detail) layout?

                   

                  I suppose it may not matter.  I think maybe what you are after is an auto-enter calc on the field itself (deselect the 'don't replace contents' option), instead of on the layout.  (Although, I think you could just copy/paste this into the CF calculation window, too.)  You might need to do some back-of-the-napkin figuring to generate some different cases, but this might work for you:

                  Case (

                     length (self ) < 10 ; textsize (self ; 14) ;

                     length (self ) < 20 ; textsize (self ; 12) ;

                     length (self ) < 25 ; textsize (self ; 10) ;

                     length (self ) < 35 ; textsize (self ; 8) ;

                    textsize (self ; 6)

                  )

                  If the question is about which field to reference, you would need to reference whichever field it is that is displaying the value.  If it's a CF calc, then this is answered for you because you put the CF calc on the layout object.  If you are, however, wanting to 'dynamically change the font of the stored value in a field' (as opposed to FileMaker's 'Conditional Formatting' for layout objects), then you would use whatever the fully qualified name of the field is - i.e. just use the field picker in the calculation window.

                   

                  (I just tested the above calculation, exactly as typed above, and it does work as described.)

                   

                  --  Justin

                  • 6. Re: Conditional formatting of selected value list item

                    Format the field to be centered vertically and then use a vertical height of two lines.

                     

                    A short value will be shown as one line and centered vertically. A long value, two lines.

                    • 7. Re: Conditional formatting of selected value list item
                      davehob

                      Thanks Jack, but I have a rather crowded popover, and can't allow 2 lines for this field (and the several others to which the same issue applies).  And when I have it set up correctly, switching the font to Arial Narrow via conditional formatting works nicely.

                      Dave.

                      • 8. Re: Conditional formatting of selected value list item
                        davehob

                        Justin,

                         

                        Thanks for this, and I'm sorry for the confusion.  The value list displays data from the actual table, but the user's selection is stored as a global id field. 

                        Although I understand that I could use an auto-enter calc, I don't want to set the font size for all situations, only in certain situations.

                        So conditional formatting is the way to go, in this case at least.

                         

                        Regards,

                         

                        Dave.

                        • 9. Re: Conditional formatting of selected value list item
                          justinc

                          Ah, I think I see.

                           

                          As for the conditions when to format, you could limit the changes to only those times you want to change it.  It doesn't have to always apply.  The calculation for a CF would, most likely, be exactly the same as that for the AE calc.  The benefit, or I suppose hazard, would be that this calculation would apply anywhere you used that field.  So, if you have another layout where you DO have enough space for the longer names, it would still adjust the font size.  So maybe a CF on only a few layouts is best.

                           

                          - J