8 Replies Latest reply on Sep 23, 2011 5:09 PM by Kristin95762

    spark list grows instead of displaying a vert. scrollbar

    Kristin95762 Level 1

      Hi

       

      I'm feeding selections in a datagrid to a list.

       

      protected function myDG_selectionChangeHandler(event:GridSelectionEvent):void

                                    {

                                              var selectedTitle:String=event.currentTarget.selectedItem.title;

       

                                              var selIndices:Vector.<int> = event.currentTarget.selectedIndices;

                                              var selItems:Vector.<Object> = event.currentTarget.selectedItems;

                                              var numItems:Number = selIndices.length;

       

                                              for (var i:Number = 0; i<numItems; i++)

                                              {

       

                                                        selectedItemsList.dataProvider.addItem(selItems[i]);                    //this works to add items to the list, but the list expands in size without adding scrollbars.

       

                                              }

                                    }

       

      Also, not able to find a solution to another problem. Naturally, selecting an item in the dg posts the selection to the list. If I then press Shift+(range of rows), I end up posting the first selected row again.

       

      Thanks

       

      Kristin

        • 1. Re: spark list grows instead of displaying a vert. scrollbar
          Flex harUI Adobe Employee

          Something needs to constrain the height of the list (and probably set minHeight=0 on the list).

          • 2. Re: spark list grows instead of displaying a vert. scrollbar
            Kristin95762 Level 1

            Hi

             

            Thanks, that's what I thought, but setting min/max height isn't solving the problem.

             

             

             

            protected function myDG_selectionChangeHandler(event:GridSelectionEvent):void

                                          {

               

                                                         var selItems:Vector.<Object> = event.currentTarget.selectedItems;

                                                         var numItems:Number = selIndices.length;

             

                                                         for (var i:Number = 0; i<numItems; i++)

                  {

                                                                          selectedItemsList.dataProvider.addItem(selItems[i]);                    //this works to add items to the list, but the list expands in size without adding scrollbars.

                  }

            }

             

             

            Thanks

             

            kristin

            • 3. Re: spark list grows instead of displaying a vert. scrollbar
              Flex harUI Adobe Employee

              How is the List constrained by its parents?  Show us the MXML surrounding the List.

              • 4. Re: spark list grows instead of displaying a vert. scrollbar
                Kristin95762 Level 1

                Hi:

                 

                here's the mxml for both the datagrid and the list. I included the datagrid because the code posted earlier is related. This is, a round-about way of studying your datagrid checkbox itemRenderer. Just seein' how Vector.<Object> works you know I suppose I should point out that the datagrid is populated from a sqlite table. That's the only other code in the file.

                 

                <s:DataGrid id="myDG"

                                                        selectionChange="myDG_selectionChangeHandler(event)"

                                                        selectionMode="multipleRows"

                                                        requestedRowCount="7"

                                                        requestedColumnCount="3"

                                                        x="44" y="25">

                                    <s:typicalItem>

                                              <fx:Object bookID="ID " title="The Title of a Book Goes Here"/>

                                    </s:typicalItem>

                                    <s:columns>

                                              <s:ArrayList>

                                                        <s:GridColumn dataField="bookID"

                                                                                        rendererIsEditable="true"

                                                                                        headerText=" "

                                                                                        width="20">

                                                                  <s:itemRenderer>

                                                                            <fx:Component>

                                                                                      <s:GridItemRenderer>

                                                                                                <mx:HBox horizontalAlign="center" verticalAlign="middle" height="100%" width="100%">

                                                                                                          <mx:CheckBox selected="false"/>

                                                                                                </mx:HBox>

                                                                                      </s:GridItemRenderer>

                                                                            </fx:Component>

                                                                  </s:itemRenderer>

                                                        </s:GridColumn>

                                                        <s:GridColumn dataField="bookID" headerText="ID"/>

                                                        <s:GridColumn dataField="title" headerText="Title"/>

                                              </s:ArrayList>

                                    </s:columns>

                          </s:DataGrid>

                 

                          <s:List id="selectedItemsList"

                                              x="309" y="184"

                                              width="228"

                                              dataProvider="{listDP}"

                                              labelField="title"

                                              maxHeight="200"

                                              minHeight="0"/>

                • 5. Re: spark list grows instead of displaying a vert. scrollbar
                  Flex harUI Adobe Employee

                  The List doesn’t have a specified height so it can grow.  I’m not sure why maxHeight isn’t taking effect.  It isn’t clear from your code snip whether DataGrid and List are actually adjacent tags in the MXML file.  There is also requestedRowCount property that might be helpful.

                   

                  There is a skill to putting the right amount of code in a post.  Too much code and nobody will read it, but too little leaves too much ambiguity.

                  • 6. Re: spark list grows instead of displaying a vert. scrollbar
                    Kristin95762 Level 1

                    Hi

                     

                    I'm using Flash Builder 4.5.

                     

                    I couldn't find a requestedRowCount property in code assist for the Spark List.

                     

                    But, actually defining the height of the list solved the problem. I knew I was missing something.

                     

                    Like so many other things, I was looking for a complicated answer to a simple problem.

                     

                    BTW, does tag proximity really affect performance as you suggest?

                     

                    Kristin

                    • 7. Re: spark list grows instead of displaying a vert. scrollbar
                      Flex harUI Adobe Employee

                      The child tags of a container can affect performance and visuals.  That’s why I don’t like code snips and encourage everyone to comment enough stuff out to boil it down to about 20 lines that actually run.

                       

                      For example, if you said your List took a long time to appear, but it was in the same Hgroup as the DataGrid, it could be the DataGrid slowing things down, not the List, or some interaction between the two.  In the snips you posted, I had to consider the DataGrid’s layout attributes in case it could be affecting how the List gets sized.  If I know the DG is in a different container either via the example code or careful description, then I know it is just a List issue.

                       

                      It therefore took me longer to read and reply.  Since answering forum posts is not an official part of my job, and I can only sneak in a certain amount of time to do it, it means that some other post will not be read and answered.  Also, people tend to learn a lot and often discover the answer themselves when boiling down the code to a simple test case.

                       

                      -Alex

                      • 8. Re: spark list grows instead of displaying a vert. scrollbar
                        Kristin95762 Level 1

                        Hi

                         

                        I kinda wondered why you asked me about the parent of the list. My list and DG were not in any container. Aside from setting up db access and a sqlstatement, those were the only 2 elements.

                         

                        But thanks for the help. I mean that sincerely.

                         

                        I am usually not too quick to jump on the forum. I usually spend a considerable amount of time scanning the net. But I have been guilty of asking too quickly a time or two. And sometimes I've even started out writing a question and found myself answering it.

                         

                        Kristin