0 Replies Latest reply on Jul 11, 2012 7:47 PM by yancaoshi

    Weird problem of Item position in TileLayout

    yancaoshi Level 1

      Please take a look at below coding. If I choose Frank and click button “age<5", the damn Frank stays still rather than the first column.

      What else should I do after refreshing the data list?

       

      Best Regards,

       

       

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
                                              xmlns:s="library://ns.adobe.com/flex/spark" title="HomeView">
        
                <fx:Script>
                          <![CDATA[
                                    import mx.collections.Sort;
                                    protected function button1_clickHandler(event:MouseEvent):void
                                    {
                                              // TODO Auto-generated method stub
                                              list.filterFunction = f1;
                                              list.refresh();
                                    }
        
                                    protected function button2_clickHandler(event:MouseEvent):void
                                    {
                                              // TODO Auto-generated method stub
                                              list.filterFunction = f2;
                                              list.refresh();
                                    }
        
                                    private function f1(item:Object):Boolean
                                    {
                                              var i:int = int(item.age);
                                              return i<20;
                                    } 
        
                                    private function f2(item:Object):Boolean
                                    {
                                              var i:int = int(item.age);
                                              return i>5;
                                    }
                          ]]>
                </fx:Script>
        
                <fx:Declarations>
                          <!-- Place non-visual elements (e.g., services, value objects) here -->
                          <s:ArrayCollection id="list">
                                    <fx:Object name="April" age="1"  sex="male" />
                                    <fx:Object name="Brown" age="2"  sex="male" />
                                    <fx:Object name="Cindy" age="3"  sex="male" />
                                    <fx:Object name="Daren" age="4"  sex="male" />
                                    <fx:Object name="Emily" age="5"  sex="male" />
                                    <fx:Object name="Frank" age="6"  sex="male" />
                                    <fx:Object name="Green" age="7"  sex="male" />
                                    <fx:Object name="Helen" age="8"  sex="male" />
                                    <fx:Object name="Ice" age="9"  sex="male" />
                                    <fx:Object name="Jack" age="10"  sex="male" />
                                    <fx:Object name="Lance" age="11"  sex="male" />
                                    <fx:Object name="Mary" age="12"  sex="male" />
                                    <fx:Object name="Nancy" age="13"  sex="male" />
                                    <fx:Object name="Opera" age="14"  sex="male" />
                                    <fx:Object name="Quntas" age="15"  sex="male" />
                                    <fx:Object name="Ray" age="16"  sex="male" />
                                    <fx:Object name="Stone" age="17"  sex="male" />
                                    <fx:Object name="Tom" age="18"  sex="male" />
                          </s:ArrayCollection>
                </fx:Declarations>
                <s:List x="69" y="57" width="320" height="320" dataProvider="{list}" itemRenderer="spark.components.LabelItemRenderer"
                                                        labelField="name">
                          <s:layout>
                                    <s:TileLayout columnWidth="100" orientation="rows" requestedColumnCount="3"
                                                                                                          requestedRowCount="3" rowHeight="100"/>
                          </s:layout>
                </s:List>
                <s:Button x="63" y="9" label="age < 20" click="button1_clickHandler(event)"/>
                <s:Button x="157" y="9" label="age > 05" click="button2_clickHandler(event)"/>
      </s:View>