9 Replies Latest reply on Oct 5, 2010 8:11 AM by daslicht

    Spark List Item Renderer

    daslicht Level 2

      Hello,

       

      I have a Spark List which got a ArrayCollection as Dataprovider and a CustomItem Renderer which include a Button.

       

      When I now press that Button i like to switch it to visible=false.

       

      Its working but also the Buttons on the non visual Items ( The Array Collection has 14 Items and the List only displays 7 at once)

      are set to visible=false.

       

      I tried it t ways:

      * by directly setting the visual property of the button inside the Item Renderer

      and

      * unsing an Event which I dispatch after finishing the action which is triggered by the button.

       

      Both approaches fail.

       

       

      In case I create a event Listener onCreateComplete It will be added  multiple times when you scroll up and down.

       

      Idea?

        • 1. Re: Spark List Item Renderer
          Flex harUI Adobe Employee

          You are trying to hide renderers?  Maybe set includeInLayout=false as well.

          • 2. Re: Spark List Item Renderer
            daslicht Level 2

            No, even simpler , I just like to hide a Button which is included in a Renderer.

             

            Basicly I have a Song List with 'AddToCart' Button and I want to hide that Button after pressing it.

             

            I just tried it by listening to and event or directly hiding it (and showing the button again once the itewm was rmoved from the shopping cart), I am working on an example to show and I hope this will open up some new insights how to solve this.

            • 3. Re: Spark List Item Renderer
              Flex harUI Adobe Employee

              If the array collection will never get very big, try setting

              useVirtualLayout=false

              • 4. Re: Spark List Item Renderer
                daslicht Level 2

                Hello and thank you for the answer.

                And what would be another approach for a large collection ?

                 

                What is large ? 100, 1000, 10000 ?

                 

                Would it work if I store the visability in form of a boolean in the array collection and bind the visibility of the button to {data.ButtonIsVisible}

                 

                Do you think that this binding could work ?

                • 5. Re: Spark List Item Renderer
                  daslicht Level 2

                  Hi,

                   

                  I have just created a Example,

                  based on my idea to store the actual visibility of the Button,

                  which is included in each Item Renderer,

                  in the DataProvider itself:

                   

                  http://wensauer.info/flex/SparkList_Example/ListExample.html (view source enabled)

                   

                  What do you think abou this, that should work even with a very Big ArrayCollection, no ?

                  • 6. Re: Spark List Item Renderer
                    George I Flex

                    Hi,

                     

                    Storing the visible true/false data into the data object should be the best approach. If you want, based on that property you can then filter the 2 lists, and only show the selected/unselected items in each.

                     

                    As for testing, you can always create some mock data of 1000 elements and see how it goes. Whatever, you do, make sure you use virtualization.

                    • 7. Re: Spark List Item Renderer
                      daslicht Level 2

                      Hi,

                      I encountered some other challenges...

                       

                      Ok here is what I basically have:

                       

                      Database Tables:

                      * Users

                      * Songs

                       

                      Objective:

                      * Allow user to save custom playlists and do not display the 'Add To Playlist' button anymore once a song is saved to a playlist

                       

                      The Songs are searchable by its properties (at the moment by its genre)

                       

                      Now hiding and reshowing the 'Add To Playlist Button' is working, but when the user start's another query, and returns to the previous,

                      the visual state of the buttons are obviously lost.

                       

                      I thought about storing each played song to a database table to keep the state and being able to save it for later usage when the user come back

                       

                      But in that case when the user select a genre, I have to compare each song if it's in the saved playlist ?

                      This sounds pretty slow?

                       

                      I also looked into the array filters but I have no clue yet how to use it for may usage.

                       

                      Any other ideas how to solve this smart ?

                      • 8. Re: Spark List Item Renderer
                        George I Flex Level 1

                        I think comparing if the sound is in the other collection is the only way to go. But it should go much faster if you do this in the db side, on the server. Try a left join between the songs list and the playlist there and that should give you the list of "still available" songs.

                        • 9. Re: Spark List Item Renderer
                          daslicht Level 2

                          Hello,

                          thanks for your answer, all songs should be displayed anytime but not the addToPlaylist button.

                           

                          Yeah on teh server side that sounds right, basically I just need to querey

                          songs, playlists for a certain user and add a boolean value to songsVO (the return value from the server side)

                           

                          Thank you I keep trying.