How to detect dataprovider change in spark List ?

The problem is : when the dataprovider changes, the List unselects its items. I want the selected item of the List to stay selected, even if the dataprovider has a new item, for example.
So I try to detect a change in the dataprovider, to be able to re-select the item that was selected before the change.
I tried to listen several events but it didn't work :
- change is dispatched by user, not by code.
- updatecompleted is dispatched when the dataprovider changes but it is triggered also when the list is resized, and I don't want that.
- collectionChange is not dispatched
I don't understand why valueCommit is not dispatched when the dataprovider changes.
Can you help me ???

There is a dataProviderChange event fired whenever dataProvider is set,
but it may not be listed in the metadata so you may not be able to access
from MXML.
Flex harUI,
Why isn't this event exposed publicly through the metadata of the class?
The easy fix I can come up with is to extend the List, by simply exposing the event, like:
          [Event(name="dataProviderChange", type="flash.events.Event")]
          public class ExtendedList extends List
But I don't know if it's good practice...

Similar Messages

  • How to detect value change of item?

    Hi all,
    We want to list all goods that customer chooses, so TileList is used to display all goods information and a custom component MyItem is used as ItemRenderer. Meanwhile a Label is used to display the sum of all the goods. The hierarchy is simply like this:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"  layout="absolute" >
    <mx:TileList id="tl" dataProvider="{acGoods}" ItemRenderer="MyItem"/>
    <mx:Label id="labelSum"/>
    </mx:Application>
    Here, acGoods is an ArrayCollection which I believe is bindable.
    User may change price inside MyItem directly, so the text of the Label need to update as well. I find that acGoods contains latest price. Now the problem is Label text stays the same. I have tried to call calculating function in set acGoods() but it doesn't work.
    Please don't sugguest dispatch event because this is only a simplified scenario. If anybody tell me how to implement this by binding mechaism, that'll be very helpful.
    Best wishes,

    protected function get totalLabelText():string {
        // for each var i:* in acGoods and so on
        return 'Calculated label here';
    <mx:Label id="labelSum" text="{totalLabelText}"/>
    Inside MyItem:
    once you changed something invoke:
    Application.application.executeBindings(true);
    Hope this will work for you

  • Detect first and last spark list items

    Hi,
    I have a custom item renderer with a background image for each item in a list. the thing is I'm trying to have a different background for the first and last items (curved respectively) and I'm not sure how to do that.
    Any help will be appreciated.

    If you are scrolling, will you change which ones have the different
    background?
    If not, look at ButtonBar.  It is based on ListBase and assigns different
    skins to the first and last renderer.

  • JColorChooser: how to detect color change?

    Hi all,
    I Know how to create a JColorChooser dialog (JColorChooser.createDialog()) to which I can add actionlistener to detect a new color has been selected.
    I want know if there is a way to detect events if I integrate the JColorChooser in a Panel, for example in this way:
    JPanel panel = new Janel();
    JColorChooser colorChooser = new JColorChooser();
    panel.add(colorChooser )Thx a lot!

    Ok, a I found a way:
    JColorChooser fontColorChooser = new JColorChooser();
         fontColorChooser.getSelectionModel().addChangeListener(new ChangeListener(){
                   public void stateChanged(ChangeEvent e){
                       System.out.println(fontColorChooser.getColor().toString());
               );

  • JFrame: How to detect a change in size?

    Hello everyone,
    I have a question related to the size of a JFrame or JPanel. I add a few JPanels to a JFrame and I wanted to detect when the size of the JFrame window or the JPanel itself had changed (if the user pressed the "Maximize icon" or simply dragged the window size from the one of the corner of the window). I am not sure if I need a listener added to the Frame, and what kind of listener that would be (if any exists, I am not sure).
    I have another question regarding the class Dimension. I add JPanel's to my JFrame and I use the class Dimension to get the size of the panel with the getSize() method. I wanted to know when is the sooner that I could call this method to get the right size. For example, I use it in a few methods like the paintComponent, the mouseReleased and mouseDragged method, but I wished to get the correct size as soon as possible and only compute it once (or update it if the JPanel sized change). I am wondering why the size is 0 while I call this method inside the constructor and if there is any method where I can call it before actually doing anything to the JFrame please.
    I hope my questions are somewhat clear.
    Thanks for all your help, it is very much appreciated.

    I am having one more issue.
    I have implemented the ComponentListener for each of my JPanel and used the componentResized and componentShown to calculate the size of my panel.
    This works great when I resize the JFrame using one of the corners, but not when the "maximize button" (in the title bar next to the corss) is pressed.
    Is there any way please to fix this? Thank you.

  • How to detect any changes of a StepType-field by the sequence ?

    Hi all,
    suppose I've got this: a simple StepType 'TEST' with one added custom field 'Source' of the type String.
    When using this StepType in a Sequence and editing the 'Source' value (from the Variables panel),
    the Sequence name is immediately marked with an '*'. Which is wat we want :-)
    But, if I change the 'Source' value from code (C#), I see that my 'Source' value is changed (in the Variables panel), but not that the Sequence has detected this.
    Maybe it's StepType-flag that I have to set or from code, executing a trigger or so ?
    Thanks in advance ?
    Franky
    Solved!
    Go to Solution.

    I'm talking to myself, but FYI:
    because I'm updating my sequence from code (C#), I've the current Step as an object and
    therefore I knows if any fields are changed.
    Using this snippet will mark my sequencefile as 'changed' : 
    step.Sequence.SequenceFile.AsPropertyObjectFile().IncChangeCount();

  • Animated Horizontal Spark List

    Hello,
    how could I animate a Horizontal Spark List and enable the Mouse-Wheel for it ?
    I like to scroll with the intervall size of the page, to get started with it I enabled snapping and set the stepsize to thewidth of the itemRenderer/List.
    How to animate this now ?
    http://wensauer.info/flex/AnimatedHorizontalSparkList/ (view source enabled)
    As you can see when you reach the last item and keep scrolling there is some pixels overhead so that you can scroll the content freely.
    How to fix this ?
    Colclusion:
    * how to enable mousewheell for the horizontal scroller (swap function with the vertical?)
    * how to animate a  spark list
    * how to remove pixel overhead
    Any Help is welcome!
    Marc

    Ok,
    I solved some questions myself.
    It is working so far to a certain extend.
    When I scroll to fast with the mouse wheel the auxilary slider gets out of sync with the List.
    Is there a way to only start a new animation once the current is finished ? can I lock it somehow or put them into a queue?
    http://www.wensauer.info/flex/AnimatedHorizontalSparkListII/
    The best way woulkd be that I can use the scrollbar of the scroller, but when I enable snapping, the animation isnt working anymore.
    Idea ? Noone ?

  • How Do You Populate A Spark List Control With An Array?

    Hello, all,
    Sorry to come accross so frustrated, but how in the name of God do you populate a Spark list control with the data in an array?  You used to be able to do this with the mx:List control, but the guys developing Flex just had to make things more difficult than they need to be!  I am more of a code purist and prefer doing things the way they have been done for decades, but apparently nothing can ever stay simple!
    I simply want to populate a list control with an array and this shouldn't be rocket science!  I found out that I must use a "collection" element, so I decided that an arrayCollection would be best.  However, after searching Adobe's documentation about arrayCollections, I am lost in a black hole of data binding, extra lines of code just to add a new element, the need to sort it, etc...!
    Here is my code:
    var pendingArray:ArrayCollection = new ArrayCollection();
    for ( var i:int = 0 ; i < queue.length ; i++ )
         var item:UserQueueItem = queue[i] as UserQueueItem ;
         if ( item.status == UserQueueItem.STATUS_PENDING )
         pendingArray.addItem({label:item.descriptor.displayName,descriptor:item.descriptor});
    Here is the relevant MXML:
    <s:VGroup>
         <s:List id="knockingList" width="110" height="100"/>              
    </s:VGroup>
    I'm not getting any errors, but the list is not populating.
    I have seen several examples where the arrayCollection is declared and populated in MXML:
            <mx:ArrayCollection id="myAC">
                <!-- Use an fx:Array tag to associate an id with the array. -->
                <fx:Array id="myArray">
                    <fx:Object label="MI" data="Lansing"/>
                    <fx:Object label="MO" data="Jefferson City"/>
                    <fx:Object label="MA" data="Boston"/>
                    etc...
               </fx:Array>
            </mx:ArrayCollection>
    That may be fine for an example, but I think this is a rare situation.  Most of the time I would image that the arrayCollection would be created and populated on the fly in ActionScript!  How can I do this?
    Thanks in advance for any help or advice anyone can give!
    Matt

    In your post it seemed like you were trying to take care of many considerations at once: optimization, design, architecture.  I would suggest you get something up and running and then worry about everything else.
    If I use data binding, then I will probably have to declare the  arrayCollection as a global variable and then I'll have to write 100 or  so extra lines of code to addItem(), removeItem(), sort(), etc...  It  just seems like too much overhead.
    I believe you may have some misconceptions about databinding in general.  You won't have to make it a global variable and you certainly won't need an extra 100 lines of code.  If you did this forum would be a very , very quiet place.
    I don't want to use data binding because the original array is refreshed  often and there is one function called by an event that re-declares the  arrayCollection each time, populates it with the array, and then sets  it as the list's dataprovider.
    That is the beauty of the ArrayCollection, it can handle the updates to its source Array. I don't know if you need to redeclare the ArrayCollection, resetting the source to the new Array allows everyone involved to keep their references so you don't have to worry about any "spooky" stuff going on.

  • How to handle multiple selection in the Spark List control with checkbox as itemrenderer?

    Hi All,
    I am using checkbox as an ItemRenderer in spark list.
    I have a query.
    how to handle multiple selection in the Spark List control with checkbox as itemrenderer?
    how to retrieve the selected item label?
    Thank you in advance.

    Hi there, I'll tweak your code a little bit to something like this:
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                    layout="vertical">
        <mx:Script>
            <![CDATA[
                 import mx.events.ListEvent;
                 import mx.controls.CheckBox;
               [Bindable]
               private var mySelectedIndexes:ArrayCollection=new ArrayCollection();
                private function onChange(e:ListEvent):void
                   if(CheckBox(e.itemRenderer).selected){
                             mySelectedIndexes.addItem(e.rowIndex);
                   }else{
                                  mySelectedIndexes.removeItemAt(mySelectedIndexes.getItemIndex(e.rowIndex));     
                   chkList.selectedIndices=mySelectedIndexes.toArray();
            ]]>
        </mx:Script>
    <mx:ArrayCollection id="collection">
            <mx:Object label="Test A"/>
            <mx:Object label="Test B"/>
            <mx:Object label="Test C"/>
            <mx:Object label="Test D"/>
            <mx:Object label="Test E"/>
            <mx:Object label="Test F"/>
            <mx:Object label="Test G"/>
        </mx:ArrayCollection>
    <mx:List id="chkList" dataProvider="{collection}" itemRenderer="mx.controls.CheckBox"  itemClick="onChange(event);" allowMultipleSelection="true"/>
    </mx:Application>

  • How do i set spark list selected item's color??

    hey guys... so got a little problem... i have a spark list which gets populated from a array collection that looks likda like this
    [0] = "name1"
    [1] = "name 2"
    [2] = "name 3"
    when i click on say "name 1" i  need the color of "name 1" to change to say red...
    and when i click on another item i need that color to stay... red on "name 1"...
    oh and... i need to do the color change in actionscript rather than the mxml file...
    any ideas???

    Hi,
    I'm not sure if this is exactly what you are looking for. What I did was created an itemRender for the list and assigned it like so
    <s:List dataProvider="{ listDataProvider}" itemRenderer="listItemRenderer"/>
    And the listItemRenderer will look some
    //Code Begins
    <?xml version="1.0" encoding="utf-8"?>
    <s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
                              xmlns:s="library://ns.adobe.com/flex/spark"
                              xmlns:mx="library://ns.adobe.com/flex/mx"
                              focusEnabled="true" >
        <fx:Script>
            <![CDATA[
                var clicked:Boolean=true;
                protected function clickHandler(event:MouseEvent):void
                        clicked?labelRender.setStyle("color","0x00FF00"):labelRender.setStyle("color","0xFF0000") ;
                        clicked=!clicked;
            ]]>
        </fx:Script>
        <s:Label  id="labelRender" text="{data}" color="0xFF0000" click="clickHandler(event)"/>
    </s:ItemRenderer>
    //Code Ends
    In the above example the colour toggles on each click. So, you can apply anything. assume you have a property called color in your array collection, you can access it as data.color and then set the text to that color when it is clicked. I hope this helps. Do write back if you have any issues.
    Nishad

  • How to search XML data from a HTTPMultiService and display the result on the Spark List

    Hello all,
    I am totally new to Flash Builder and Actionscript and hope someone might be able to help me out. I basically create a mobile app with a single view. The view has a TextInput as a search box and a search button. I conntected a Data/Service using a local XML file and bind the Data to a Spark List. Innitally the List will show nothing until the user enter the search term and hit the button. The List suppose to show the XML data that match the search term.
    Now is my problem. I cannot make the List to show the data that match the search text. The List just shows ALL the data.
    Here are my MXML code:
    <?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"
            xmlns:shopping="services.shopping.*"
            title="Search">
        <fx:Script>
            <![CDATA[
                import mx.events.FlexEvent;
                protected function button1_clickHandler(event:MouseEvent):void
                    navigator.popView();
                protected function list_creationCompleteHandler(event:FlexEvent):void
                    getDataResult.token = shopping.getData();
                protected function seach_clickHandler(event:MouseEvent):void
                    getDataResult.token = shopping.getSearchData(searchTxt.text);
            ]]>
        </fx:Script>
        <fx:Declarations>
            <s:CallResponder id="getDataResult"/>
            <shopping:Shopping id="shopping"/>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
        </fx:Declarations>
        <s:actionContent>
            <s:Button height="79" label="Back" click="button1_clickHandler(event)"/>
        </s:actionContent>
        <s:List id="list" left="0" right="0" top="111" bottom="0"
                creationComplete="list_creationCompleteHandler(event)" labelField="english">
            <s:AsyncListView list="{getDataResult.lastResult}"/>
        </s:List>
        <s:TextInput id="searchTxt" x="80" y="34" width="250" height="49" enabled="true"
                     prompt="search..."/>
        <s:Button id="search" x="338" y="35" width="72" height="49" label="s"
                  click="seach_clickHandler(event)"/>
    </s:View>
    Here is the _Super_Shopping.as file:
    * This is a generated class and is not intended for modification.  To customize behavior
    * of this service wrapper you may modify the generated sub-class of this class - Shopping.as.
    package services.shopping
    import com.adobe.fiber.core.model_internal;
    import com.adobe.fiber.services.wrapper.HTTPServiceWrapper;
    import com.adobe.serializers.xml.XMLSerializationFilter;
    import mx.rpc.AbstractOperation;
    import mx.rpc.AsyncToken;
    import mx.rpc.http.HTTPMultiService;
    import mx.rpc.http.Operation;
    import valueObjects.Shop;
    [ExcludeClass]
    internal class _Super_Shopping extends com.adobe.fiber.services.wrapper.HTTPServiceWrapper
        private static var serializer0:XMLSerializationFilter = new XMLSerializationFilter();
        // Constructor
        public function _Super_Shopping()
            // initialize service control
            _serviceControl = new mx.rpc.http.HTTPMultiService();
             var operations:Array = new Array();
             var operation:mx.rpc.http.Operation;
             var argsArray:Array;
             operation = new mx.rpc.http.Operation(null, "getData");
             operation.url = "assets/data/shopping.xml";
             operation.method = "GET";
             operation.serializationFilter = serializer0;
             operation.properties = new Object();
             operation.properties["xPath"] = "/::shop";
             operation.resultElementType = valueObjects.Shop;
             operations.push(operation);
             operation = new mx.rpc.http.Operation(null, "getSearchData");
             operation.url = "assets/data/shopping.xml";
             operation.method = "GET";
             operation.resultFormat = "text";
             argsArray = new Array("item");
             operation.argumentNames = argsArray;
             operation.properties = new Object();
             operation.properties["xPath"] = "/::shop";
             operation.resultElementType = valueObjects.Shop;
             operations.push(operation);
             _serviceControl.operationList = operations;
             preInitializeService();
             model_internal::initialize();
        //init initialization routine here, child class to override
        protected function preInitializeService():void
          * This method is a generated wrapper used to call the 'getData' operation. It returns an mx.rpc.AsyncToken whose
          * result property will be populated with the result of the operation when the server response is received.
          * To use this result from MXML code, define a CallResponder component and assign its token property to this method's return value.
          * You can then bind to CallResponder.lastResult or listen for the CallResponder.result or fault events.
          * @see mx.rpc.AsyncToken
          * @see mx.rpc.CallResponder
          * @return an mx.rpc.AsyncToken whose result property will be populated with the result of the operation when the server response is received.
        public function getData() : mx.rpc.AsyncToken
            var _internal_operation:mx.rpc.AbstractOperation = _serviceControl.getOperation("getData");
            var _internal_token:mx.rpc.AsyncToken = _internal_operation.send() ;
            return _internal_token;
        public function getSearchData(item:String) : mx.rpc.AsyncToken
            var _internal_operation:mx.rpc.AbstractOperation = _serviceControl.getOperation("getSearchData");
            var _internal_token:mx.rpc.AsyncToken = _internal_operation.send(item);
            return _internal_token;
    The getSearchData() supposed to return XML data that match the search text, but it doesn't. Can anyoen help?
    Thank you!

    Hi,
    are you able to change dynamically the  operation.url = "assets/data/shopping.xml";?
    i need to do that based on the users input.
    Thanks in advance,

  • How to make change in Issue list across all project sites?

    Hi,
    We all have issue list in our project sites. We need to add some values to some of the columns in that issue list. The requirement is we need these changes to reflect in all the new sites. Also how to make these changes reflect in current existing sites.
    Can anybody suggest a way to achieve this. One thing that i am aware of is creating a new project site template and associating it with EPT but that still not solves the issue for preexisting sites.
    Please help asap.
    Thanks in advance.

    Hi SpWrk
    If you have already created some sites. You would need to apply these changes either Programetically (Powershell or C#) or Manually.
    However, you can take the following approach to avoid this problem in future. (i.e. Your "future" changes will appear in existing sites too). I am writing the procedure breifly but let me know if you need more details on this
    1) Create a content type (e.g. "Project issues" at PWA level)
    2) Associate this content type with the Issues List in your site template as well any existing project sites. Make it a default content type for Issue lists. save your site template
    3) Create all your custom columns in this new Content type (changing OOB issue columns can break your reporting)
    4) Your changes to content type should reflect in future sites as well as existing sites (whereever the content type was appiled)
    Regards
    Hammad Arif EPM Advice Blog

  • How to intercept style changes in skin for spark Button?

    How to intercept style changes in skin for spark Button?
    Thank you.

    How to intercept style changes in skin for spark Button?
    Thank you.

  • How do I change my Discussions List Alias

    Cannot seem to change my discussion lists Alias.
    Went to "My Setting" and also to "My Public Profile" and did not see a place to edit and change my alias.
    Any help would be appreciated.

    Hi Jack!
    "Will have to decide to change my account..."
    Here is some additional info.
    As you have discerned, the Alias of the account you are using, cannot be changed, but you can create a new Discussions Account, with an Alias that you prefer.
    You cannot delete your present account. Just stop using it, after you have created a new one.
    You can use all of the same info in the new account, Email address, User name, etc, just be sure to insert a new Alias of your choosing.
    But your Level2#), Points(425), Total Posts(804), Total Posts Online(605) and Registered Date(7/6/02), will not be transferred.
    In the new account, your Post Counts, Points, & Level Status will all start at 0. Your Registered Date will be the date you create the new account.
    Your old account, with your previous counts & level, will still be viewable, under the old Alias.
    After you quit using the old account, those posts, will be archived. What that means is, that if there are no additional responses in the Threads they reside in, the Topics will get continually pushed down on the Topics list. After a certain amount of time, maybe 2 to 6 months, the Threads will be locked, so no responses can be entered. But the Threads will not disappear.
    Threads in heavily trafficked Forums, may be archived more rapidly than those in areas, with less activity.
    The Topics that you started using the old account, will show your Old Alias, in the Author field of a main forum page, but eventually, readers will have to keep going to the succeeding pages to view them.
    If someone were to do a Discussions Search, using these parameters:
    Restrict by Category or Forum: All Categories
    Restrict by Date Range: All
    Restrict by Username: Your Old Alias
    all of your posts, created since about 11/13/05, would be found.
    To create a new account,
    Log out of Discussions. Delete the Apple Cookies in your browser preferences. Then follow either of these instructions.
    -How Do I Create My Account?
    If you haven't signed up for an Apple ID for the Apple Store or AppleCare Support website (or forgot your old one), you can create a new account on the My Info webpage. Just click the "create one" link on the right side of the My Info page. Choose your country location and preferred language from the appropriate pop-up menus, then click Create Account. In the resulting page, enter a unique name (such as your email address) in the Apple ID field and fill in your other relevant information accordingly (fields marked with * are required). Click Continue to complete the process.
    -To register, click Login in the sidebar on the right side of the Discussions page. In the resulting page, click the "create one" link at the bottom of the page, then click "create one" in the subsequent page and follow the instructions to create an Apple ID. For more information, see the Apple ID FAQ page.
    ali b

  • Spark list: how to unselect multiple items programmatically?

    Hi, I have a spark list with multiple selection allowed. I want to add a button next to the list with which to deselect all selected items. How do I go about that? I tried to set myList.selectedItems = null, and myList.selectedItems = new Vector.<Object>, but to no avail. Help would be very much appreciated!

    Hi Sam,
    According to your description, my understanding is that you want to update multiple items in another list when updated a list item.
    In the event receiver, you can update the multiple item using Client Object Model.
    Here is a code snippet for your reference:
    public override void ItemUpdated(SPItemEventProperties properties)
    string siteUrl = "http://sp2013sps/sites/test/";
    ClientContext clientContext = new ClientContext(siteUrl);
    List oList = clientContext.Web.Lists.GetByTitle("another list name");
    ListItem oListItem = oList.GetItemById(1);
    oListItem["Title"] = "Hello World Updated!";
    oListItem.Update();
    clientContext.ExecuteQuery();
    Best regards,<o:p></o:p>
    Zhengyu Guo
    Zhengyu Guo
    TechNet Community Support

Maybe you are looking for

  • Flash Player not installing for IE8

    I'm trying to install Flash Player into my IE8, but when I go to "Get Adobe Flash Player", it brings up a page saying "Sorry Adobe® Flash® Player is not available from Adobe.com for your device's operating system or browser." I checked the 'supported

  • Compressor crash when trying to send a task with watermark

    Hello, I use Compressor without problem except when i try to add a watermark on my movie. It crash without sending the job. My watermark is a TGA file with an alpha channel. I haven't find any solution until now... Thank you for your help.

  • All_tab_columns and all_tab_cols

    Hey guys, I've come across this problem, what can I do? I know what all_tab_cols and all_tab_columns are supposed to have information about all the tables in the database and that they're very useful. The problem is, all_tab_cols will show that a cer

  • Functional Area update in FAGLFLEXP table

    Hi We have activated Cost of sales accounting in ECC6 and defined the Functional Area in the Cost Center. When we do CO Planning using KP06, ths system is not updating COSP and FAGLFLEXP tables with functional area. Request to know if anyone knows ho

  • How to read encrypted files

    i cant seem to read some files on notepad it all look like gibberish