DataGrid fitting to content

How to set DataGrid column width fit to its content dynamically.

Here is a basic example. Notice the use of outerDocument and how I removed width="100%" from the Text control. Also notice my use of measuredWidth instead or width.
As I said, this can get complex and might not always work, but in theory, it can be done.
If this post answers your question of helps, please mark it as such.
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
  <mx:Script>
    <![CDATA[
      import mx.collections.ArrayCollection;
      public var localVar:String="Application localVar";
      [Bindable] private var initDG:ArrayCollection = new ArrayCollection([
        {Artist:'Pavement', Album:'Slanted and Enchanted', Price:11.99},
        {Artist:'Pavement', Album:'Brighten the Corners', Price:11.99}
    ]]>
  </mx:Script>
  <mx:DataGrid id="myGrid" dataProvider="{initDG}"
    variableRowHeight="true">  
    <mx:columns>
      <mx:DataGridColumn dataField="Artist"/>
      <mx:DataGridColumn id="albumCol" dataField="Album">
        <mx:itemRenderer>
          <mx:Component>
            <mx:VBox>
              <mx:Text id="albumName"
                text="{data.Album}"
                creationComplete="outerDocument.albumCol.width=albumName.measuredWidth"/>
            </mx:VBox>
          </mx:Component>
        </mx:itemRenderer>
      </mx:DataGridColumn>   
      <mx:DataGridColumn dataField="Price"/>
    </mx:columns>      
  </mx:DataGrid>     
</mx:Application>

Similar Messages

  • How to force a container redraw to fit-to-content?

    Hi,
    This has been driving me crazy for a long time now.
    Example:
    <panel id="outer">
    <panel id="inner">
    <textarea text="blah blah blah"/>
    </panel>
    </panel>
    The above works fine, the outer panel's size perfectly fits
    its content.
    But if the mxml starts out with only the outer panel, and
    then I add the inner panel as result of some user event at a later
    time, then outer panel will not resize to fit. It will be really
    small and just add some scrollbars when the new content is added.
    I've tried several combinations of the following on the
    various elements with no luck...
    container.invalidateDisplayList();
    container.invalidateSize();
    container.validateDisplayList();
    container.validateNow();
    container.validateSize(true);
    Doing these things seem to have no effect. Arrgh.. please
    help!
    Thanks

    Thanks Greg, you are right. It does work. I guess my problem
    was related to the fact that I had a more complex hierarchy of
    containers, including an HDivideBox which apparently will not
    resize. So taking out layout=absolute, and cleaning up my container
    hierarchy seems to have fixed the problem. Your answer got me back
    on the right track.

  • Sizing a TextView to fit its contents (e.g., tooltip, chat bubble, etc.)

    In Flex 3, with a Text component, I can make the component fit its contents (use case: multi-line tooltip, chat-bubble) so that I restrict the max width and the height grows as necessary.<br /><br />To do this in Flex 3, you need to patch the Text component, e.g.<br /><br /><?xml version="1.0" encoding="utf-8"?><br /><mx:Text xmlns:mx="http://www.adobe.com/2006/mxml"><br />     <!--<br />          Text fields do not wrap correctly as reported in this bug:<br />          https://bugs.adobe.com/jira/browse/SDK-12826<br />          <br />          This fix, suggested by Mike Schiff, fixes the issue, so that we can set a minWidth of 0, <br />          maxWidth, and width=100% and have speech bubbles correctly size themselves.<br />          https://bugs.adobe.com/jira/browse/SDK-12826#action_157090<br />     --><br />     <mx:Script><br />          <br />               override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {<br />                    super.updateDisplayList(unscaledWidth, unscaledHeight);<br />                    textField.wordWrap = textField.wordWrap || (Math.floor(measuredWidth) != Math.floor(width)); <br />               }<br />          <br />     </mx:Script><br /></mx:Text><br /><br />Then you can:<br /><br /><naklab:TextWithWrap<br />    htmlText="{someText}"<br />    width="100%"<br />    maxWidth="220"<br />    minWidth="0"<br />    fontWeight="normal"<br />    fontSize="12"<br />    color="#000000"<br />/><br /><br />I cannot find a way to do this with the TextView component in Gumbo. How would you recommend making a TextView component fit its contents and should I file an ECR on this or am I missing something? (Otherwise, how would you handle the use cases above in Gumbo?)<br /><br />Thanks,<br />Aral

    OK, the forum ate my code :(
    Not sure how to get it to display. Feel free to close the topic as it doesn't make sense. I'll ask elsewhere.
    Thanks,
    Aral

  • Dynamic sizing of a component to fit the content

    Hi All,
    How can I make my component so that it will be dynamically sized to fit the content height?  I would like to create a component that will have a variable height.  It has a serious of user input controls.  Depending on the answers given, more input from the user may be necessary--specifically, they will have to provide an explanation in a textbox.
    So, my thinking is that I don't want to display the textbox unless they answer "yes" to any questions that require additional explanation.  If they do, then I want display the TextArea control along with instructions to enter an additional explanation here.
    However, when I do that, it will cause my component's height to grow.  I don't want to reserve space for that textbox in the component's dimensions--I would prefer it simply grow (pushing anything below it further down) if and when the textbox appears.
    How would I go about doing this?
      -Josh

    I think the standard JSF solution would be not to do the create/delete of inputs on the client side, but to do it on the server side.
    If that is not your cup of tea, I think that the standard components will not be sufficient. So you are looking at either not binding the inputs to a component and just getting the values via the request parameters or creating a custom component capable of dealing with this.

  • Adobe's Pan|Zoom component not fitting the content area

    I'm calling centerView method on handleLoadComplete event (ImageViewer.as) so the image will be adjusted to fit the content area when load is complete, but I'm having problems when testing this on Internet Explorer. Using Firefox it works fine, but on IE it only works after pressing Ctrl + F5.
    Do you know how can I fix this?

    Hi.
    Making it zoom and pan was a bit tricky, but I had it done
    two months ago (in july). The integration of the pan zoom with
    callout ("kind of spots on the map", the other published FIG
    componet) repositioning was bit tricky.
    I solved it with pointTransformations, but it was too
    expansive, in terms of memory. In my first trial, theyre positions
    were recalcuted as you pan and zoom.
    Now, in the version I published here
    http://www.gabriela.trindade.nom.br/?p=61
    you dont hav smooth zooming, and the callouts only are
    repositioned after your drop the map.
    I am working now on it. Im probably going to make then blurry
    or transparent while panning, but as I got this message from the
    foruns and I had promissed another guy who contacted me a (working)
    version, I decided to publish it on my blog.
    Hope it will be usefull.
    Please, be aware that not really a small application: it has
    lots of classes. Please read it all before contacting me with any
    doubts.
    Best luck :0)

  • Fit to contents does not fit

    How do I set up the stage to it fits the contents exactly?
    There is always a border of 100 or so pixels.
    Basically I have to batch extract a bunch of images from FLA
    files and put them in their own .fla so I can batch publish them
    with a project file. So another solution could be is there a way to
    batch export the FLAs as images? The image files do not have that
    extra space around the images. Thanks ahead.

    ok so I figured it out. Match Content does not necessarily
    mean match content, it means set the stage to the content AND add
    equal spaces around the content. So if you want to fit just the
    content, move the content to the upper left hand corner.
    Not sure if this is rtfm case, i mean I can write a function
    that says add but in the manual it explains that the add function
    actually adds and subtracts.

  • Can you set object style to Fit to Content?

    Hi all,
    I'm setting up a document for an exhibition showguide and before I get too bogged down, I could do with some help.
    Each exhibitor gets a text entry, with a logo alongside. There will be a few hundred exhibitors in total.
    To make things as easy as possible (I hope) I've made a anchored image frame to hold the logos (40mm wide x 40mm tall), which is anchored to the Company Name. This should mean that the logo stays with the correct entry at all times.
    Once I've put my text in, I will have a couple of hundred empty image frames into which I can drag and drop the logos. I've set the 'Fitting on Empty Frame' to Fit Content Proportionally so that the logos all fit nicely.
    The problem is that, after I have placed all the logos into the document, I want to make all the anchored logo frames change from Fit Content Proportionally, to FIt Frame to Content, so that the frame will shrink around any logos that are less than 40mm tall.
    I can't find a way of doing this.
    Is there a way to select all anchored objects, so that I can change the Fit setting in one hit?
    Or, is there a way to set the object style to Fit Frame to Content?
    I feel that I should be able to automate this, but the process/solution is eluding me.
    Cheers
    Colin

    As far as I know, the only way to do this would be by script after the images have all been placed. You should ask over in scripting.

  • Relink & Fit to content multiple images

    Using InDesign CS6 w/ Mac
    I've got a document with multiple different images (2000+), I want to replace all of them with 1 single image and Fit Frame to Content them all. Is this possible? I've searched extensively but can't find the answer anywhere!
    More Details:
    The document consists of a large number of tables with "check mark" and "x" images. I want to replace all the check marks with a better looking and larger check icon. Same with the X marks.
    I can do this one by one:
    Select in Links Window
    Relink > choose the new image
    Fit Frame to Content
    But with thousands of different images it would take weeks :\ Selecting multiple images in the links window doesn't work since it still asks me to select the same image each time. Help please!

    You should probably ask this in Scripting....
    InDesign Scripting

  • Re: Resize JTextPane to fit HTML content

    Where are you getting the HTML from? If you just want it to have a scroll bar you don't have to worry about calculating its size. Just do this.
    JScrollPane textScrollPane = new JScrollPane();
    textScrollPane.getViewport().add(textArea);
    textPanel.add(textScrollPane); now the text area will automatically add the horizontal bar
    when the data is larger than the view.

    Victor,
    In my experience, the Resize command will only be available if something will change if the action is taken. For instance, if you have some text in a cell that is a longer string than will fit in the column, Resize column to fit content should be available. If you click on that command, it will become unavailable, because it now will have no effect if clicked again. If you increase the font size, the row size may increase to fit the new text size. If you reduce the text size, the Fit command will become available for that row. If used, the command will again become unavailable until needed again.
    Remember that only selected rows and columns are affected.
    Regards,
    Jerry

  • Spry Accordion menu - How do you make tabs without content and make panel height fit the content?

    I have an Accordion Menu on my site and I would like to put a tab at the top that links to my homepage when clicked, instead of sliding open to show a content panel. I don't have any extra info to put in the content panel, so it would look kind of redundant to have it there.
    Also, each panel has a different amount of content, but they all default to the same height to fit the largest content. I want them to fit to the content of each panel. The only thing I've read said to set the height of the content panel to 100% in the CSS, but it didn't change anything.
    Thanks!
    Andrea
    http://www.andreamutsch.com

    You make it look so simple but it doesn't seem to be working for me...
    My first thought with getting rid of the tab content was to simply delete it, but when I do that I get a warning that 'The structure of the accordian appears to be damaged'. Then when I preview none of the tabs will open.
    This is what my accordian structure looks like with the tab content code deleted...
    <div id="Accordion1" tabindex="0">
          <div class="AccordionPanel">
            <div class="AccordionPanelTab">home</div>
            </div>
          <div class="AccordionPanel">
            <div class="AccordionPanelTab">graphic design</div>
            <div class="AccordionPanelContent">
              <p align="center">identity </p>
              <p align="center">print </p>
              <p align="center">packaging</p>
              <p align="center">web </p>
            </div>
          </div>
    <div class="AccordionPanel">
            <div class="AccordionPanelTab">photography</div>
            <div class="AccordionPanelContent">
              <p>traditional</p>
              <p>digital</p>
              <p>retouch</p>
            </div>
          </div>
          <div class="AccordionPanel">
            <div class="AccordionPanelTab">contact</div>
            <div class="AccordionPanelContent">
              <p>email me</p>
              <p>design quote</p>
              <p>purchase photography</p>
            </div>
          </div>
          <div class="AccordionPanel">
            <div class="AccordionPanelTab">resume</div>
            <div class="AccordionPanelContent">download resume (.pdf)</div>
          </div>
          <div class="AccordionPanel">
            <div class="AccordionPanelTab">design blog</div>
            <div class="AccordionPanelContent">2009</div>
          </div>
    Also, getting rid of the height in the CSS had no effect (I did this before I did the above)
    Below is my current CSS for the Panel Content
    .AccordionPanelContent {
        overflow: auto;
        margin: 0px;
        padding: 0px;
        font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
        font-size: large;
        background-color: #633408;
        font-weight: normal;
        word-spacing: normal;
        text-align: center;
    Also there is a note in the CSS that says this...
    * Anyone who styles an Accordion *MUST* specify a height on the Accordion Panel
    * Content container.
    I'm not sure how accurate that is since I don't have a height in there and it worked (although not how I wanted) but I just thought I would throw it in.

  • Fit to content

    Let's say I have a text field that can contain only 1 word or a whole sentence. How can I make this field to automatically adjust to the content in it?
    meaning if content is smaller than the width of the filed, so that the field automatically gets shorter.
    This prevents having a large blank space between the next field.

    Hello Joos,
    There is no way to shrink the box size down to match the data that will be comming back, only expanded to the maxiumum that designer would want shown. There is an option in the format expert called "Can Grow" and this will expand the field vertically if the data is longer than the box. There is currently no method to expand the same way horizontally.
    Hope this helps,
    -Sean

  • Sizing a scrollPane to fit its contents' width and height

    Hi,
    I have a MC loaded into a ScrollPane and have attempted to
    detect the MC's width and height and use that to set the size of
    the scrollPane per the documentation at
    Adobe
    Live Docs. I am probably not adapting the code correctly (well,
    duh), but what I have isn't working and I don't know why. Does
    anyone around here have a clue? Thanks in advance.

    OK, the forum ate my code :(
    Not sure how to get it to display. Feel free to close the topic as it doesn't make sense. I'll ask elsewhere.
    Thanks,
    Aral

  • How to fit frame to content when content contains anchored text box?

    Hi there
    I am creating a series of inline text frames within a text frame. Each of these inline frames contains text which includes an anchored text frame. If I tell my inline frames to fit to content they seem to ignore the anchored frames contained therein. Is there any way I can get them to consider the anchored frames they contain when they fit to content?
    I tried checking the geometric bounds of my anchored frame before and after its parent frame has fitted to content. Even when there has been no change in position the bounds after fitting to content seem to give numbers way off. I thought I might be able to reset the geometric bounds of the containing frame manually if the anchored frame therein had moved with the fit frame to content.
    Here is a snippet of my code:
    var anchoredBounds = anchoredFrame.geometricBounds;
    mainFrame.fit(FitOptions.FRAME_TO_CONTENT);
    mainFrame.texts.item(0).recompose;
    var newAnchoredBounds = anchoredFrame.geometricBounds;
    alert(anchoredBounds[0] + "; " + newAnchoredBounds[0]);
    So “mainFrame” is the text frame containing text and the anchored frame, “anchoredFrame”. “anchoredBounds[0]” seems to correlate with the top edge of the frame when I check it manually after the script has finished (when it hasn’t move with the fit to content). “newAnchorBounds[0]”, however, always gives numbers that are way off every time. Any ideas why this would be the case?
    And most importantly, can anyone suggest how I can get my “mainFrame” to consider the “anchoredFrame” contained in it when it fits to content?
    I’m using CS4 on a PC. Let me know if it would help to post more code, or if I haven’t explained myself clearly enough.

    Is there any way I can get them to consider the anchored frames they contain when they fit to content?
    @Graham – as long as ALL the anchored text frames are "inline" text frames,
    mainFrame.fit(FitOptions.FRAME_TO_CONTENT);
    should work as expected or at least sort of *.
    Without calculating anything at all.
    Just tested in InDesign CS5.5 (v7.5.3).
    Could it be that CS4 will fail on that?
    Of course, you can only rely on this, if the main text frame contains any "real" text at all. Not only the  special characters representations of the "inline" text frames. In that case the fit() method will do nothing at all.
    * it's debatable, if the fit() method yields desirable output.
    It depends on your expectations.
    See the following examples:
    1. Case 1:
    Text frame before fitting:
    2. Case 1:
    After fitting with the UI command, context menu: "fit frame to contents"
    (note the gap between the last baseline of the text and the text frame; note also  the new width)
    Is that the result you would expect? I guess not.
    3. Case 1:
    After fitting  programmatically with myTextframe.fit(FitOptions.FRAME_TO_CONTENT);
    4. Case 2:
    Before fitting
    same text frame as in #1, but different height
    5. Case 2:
    After fitting with the UI command, context menu: "fit frame to contents"
    A different width than in #2 and a gap at the bottom of the text frame!
    Not the desired result, I'd say…
    6. Case 2:
    After fitting  programmatically with myTextframe.fit(FitOptions.FRAME_TO_CONTENT);
    Same result as in #3
    So with scripting we could, at least, get consistent results.
    Of course, you could get the same results in the UI, if you double-click on the bottom center control point…
    Maybe it helps, if you are showing us some screen grabs:
    1. Your starting point
    2. The desired result
    Uwe

  • Fit Content To Frame Crashes InDesign CS3 !

    Hi
    iam try to fit the content to it's frame
    if(Utils<Facade::IFrameContentFacade>()->CanFitContentToFrame(UIDList(newPageItemRef)))
    ErrorCode err=Utils<Facade::IFrameContentFacade>()->FitContentToFrame((UIDList(newPageItemRef)));
    But whenever I execute this methos InDesign CS3 crashes..
    Wht could be the reason??
    thanks,
    nataraj

    You probably need to pass the content item and not the frame.
    Use IHierarchy to navigate to the first child item of
    newPageItemRef and pass that to FitContentToFrame instead.

  • Frame doesn't fit content

    Hi!
    One of my collaborator has a problem seeing my project. On my side, I've tried it on Chrome, Explorer and Firefox, it work very well (project is on our server). But on his side, the frame doesn't fit the content. As you can see in the picture the two buttons at the bottom right aren't totally showed. We are 5 to try and only him has this problem. What can it be ?

    Hi there
    What is the operating system your collaborator is using?
    Cheers... Rick
    Helpful and Handy Links
    Captivate Wish Form/Bug Reporting Form
    Adobe Certified Captivate Training
    SorcerStone Blog
    Captivate eBooks

Maybe you are looking for

  • Getting a compilation error when deploying a web service to OC4J.

    The following are the error that I got from Oracle AS server console: [Feb 5, 2007 11:31:14 AM] Application Deployer for edsssaws STARTS. [Feb 5, 2007 11:31:14 AM] Copy the archive to D:\product\10.1.3\OracleAS_1\j2ee\home\applications\edsssaws.ear [

  • Unable to create the test suite file

    Hi, I imported a BPEL project to my JDeveloper ver 10.1.3.3.0. When I clicked on the <project name>.bpel, I got the "unable to create the test suite file" error and all the partnerlinks have a bang sign (!). None of the partner link works. Please hel

  • Need valuable guidance to make a peformance oriented query, trying to replace unions with analytical function

    Hi,    Please find below table structure and insert scritps. Requesting for vluable help. create table temp2 (col1 number,col2 varchar2(10),col3 number,col4 varchar2(20)); insert into temp2 values (1,'a',100,'vvv'); insert into temp2 values (2,'b',20

  • "No authorization to display partner in role".

    Hi We are in SRM4.0 SP12 and we have buyer completion workflow -after which the SC goes for cost center owner approval. In case of goods SC the cost center owner carries out the approval process as desired. However, in case of service shopping cart w

  • How to limit date fields between 2 values

    Hi I have two date fields and I can use min and max to limit them between two values. But what I wanna do is make it so that the user can only insert values before June 30th each year. So if a value is over that it gives an error. Right now I can do