Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Get TitleWidth

    Hi,

    I would like to know the exact, actual, title with of a dynamic form (first column). I did not find any method which returns this... I've tried getAttribute(), but it does not return the actual value, just the configured (default) one.

    Is there anything in the API which can return this information?

    Many thanks,

    Thomas

    #2
    Hi Thomas,

    I think this is missing from the framework (4.1p). There is setTitleWidth(), but no getter for it.

    Best regards,
    Blama

    Comment


      #3
      To get this information requires drawing offscreen and measuring the result, so it's expensive to get.

      Basically you would take the text who size you want to know and place in a Canvas as contents, replicating the font, font size and spacing that the form will use exactly (eg, take into account the setting for cellPadding). Set the Canvas to width 1, place the Canvas at a negative top coordinate to put it offscreen, draw() it, and check getVisibleWidth().

      Obviously this is fairly advanced and is an expensive operation, so don't start down this road lightly.

      Comment


        #4
        Many thanks. It seems to be a bit too much, as you suggests :-)
        Actually, what I want to do is ensuring that the title width of multiple dynamic forms (working on different data sources) are the same, to have a clean page with everything aligned. Any other way to do this ?

        Thanks,

        Comment


          #5
          You can of course just set it to the same value, assuming that value is larger than any actual title is rendered in either form. Other than that, you would have to measure.

          Note you can also set a reasonably large value, then enable clipItemTitles so very long titles are just clipped and a hover is shown.

          Comment


            #6
            Giving a fixed value is difficult for us, as the language can be changed on the fly, and some titles become a lot larger in some cases.
            I did not know about this clipTitle option, that's interresting and may be a good option. Thank you for your advice!

            Comment

            Working...
            X