4 Replies Latest reply on Jan 20, 2011 8:46 PM by Santanu Karar

    ItemRenderer height issue

    Santanu Karar Level 1

      Hi,

       

      I'm using an AdvancedDataGrid component, and an extended Text component as it's itemRenderer. The ADG sets editable = true. The problem I'm facing is, say I've an one line text in my datagrid row, so the itemRenderer takes an height of around 25 pixels. When I'm edit any cell and put a large text, the itemRenderer takes it's adequate height properly as expected. But when I'm re-edit that cell and put a very small text value, the row doesn't propertly resize to it's one line height. I've tried explicitely call invalidateResize(), invalidateDisplaylist() etc. etc. inside from the Text itemRenderer component - but no use. After a few multi edit in the row, the row takes its earlier height as expected; but it not resizes properly after an edit from long text to smaller text.

       

      Is there any way to manipulate this to work properly (?)

       

      Any advise will be real helpful.

       

       

      Thank you.

       

      Regards,

       

      Santanu Karar

        • 1. Re: ItemRenderer height issue
          Flex harUI Adobe Employee

          See the post on my blog about variableRowHeight

           

           

          --

          Alex Harui

          Flex SDK Team

          Adobe System, Inc.

          http://blogs.adobe.com/aharui

          • 2. Re: ItemRenderer height issue
            Santanu Karar Level 1

            Hello Alex,

             

            First of all - thank you, for helping me to solve this problem. This indeed a silly problem while handling list based component and item renderers. Well, some of the facts which I found, might you like to know..

             


            1. In you itemRenderer component which holds a Text component, has it's width as: width={explicitWidth-20}. Well, it even works if I use width={this.width}.

            2. In the ADG which I'm using, had all the columns one type of Text extended item renderer and only one column has another type of item renderer - Canvas. Removing that another type of item renderer makes my Text item renderer as fantastic way as I need it.

            3. I learnt one thing - in itemRenderer component, if you dealing with text (probably multiline texts), do NOT use a width anywhere - including no percentage width, no static width. You can use percentage as height, but not use width. Because if somewhere any mention of width even present, "width=explicitWidth" even won't work; and if you don't have any width anywhere mentioned, you may not even needed to call explicitWidth.

             

            Please, let me know if you have any thought over these.

             

            And thank you once again.

             

             

            Regards,

             

            Santanu Karar

            • 3. Re: ItemRenderer height issue
              Flex harUI Adobe Employee

              1. I used -20 to get some padding.

              2.  I'm not sure how the Canvas renderer would cause a problem unless it was

              also not measuring correctly.

              3.  Whenever you use .width, you are also setting explicitWidth and removing

              flexibility.  Whenever you use percentWidth, the measurements will be based

              on the natural content size, which is not always what you want.  The item

              renderer contract requires that you tie your measurements to the

              explicitWidth on the renderer.

              • 4. Re: ItemRenderer height issue
                Santanu Karar Level 1

                I'm agreed with your 3rd point Alex. Calling any kind of width (fixed or percentage) could starts trouble with itemrenderer component. In my case when I'm using a Text component as itemRenderer, I did not even needed to call explicitWidth. When I'm using a UIComponent renderer and inside a Text component then I followed your suggestion (width={explicitWidth-20}). Thank you for giving these helpful tips Alex!