Flex List ItemRenderer : Change States from parent ?

Hai there,
So i created a list that uses an arrayCollection as dataProvider and an itemRenderer with 2 states : LabelState and ProgressState, the labelState is the start state and shows a Filename, the progressState is the state i need to change to when i press a "Start Upload" Button.
This is the itemrenderer :
<?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"
autoDrawBackground="true" currentState="LabelState" width="800">
<s:states>
<s:State name="LabelState" />
<s:State name="ProgressState" />
</s:states>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
public function changeState():void
trace("changing state for " + label_field.text);
this.currentState = "ProgressState";
trace(this.currentState);
]]>
</fx:Script>
<s:Label name="label_field" paddingLeft="10" maxHeight="40" paddingTop="10" paddingBottom="10" id="label_field" width="800" color="#333333" includeIn="LabelState" text="{data.label}"/>
<mx:ProgressBar id="progress_field" left="3" top="3" bottom="3" mode="manual" chromeColor="#0096FF" includeIn="ProgressState" textAlign="center" labelPlacement="center" maximum="100" color="#FFFFFF" right="3"/>
</s:ItemRenderer>
This is the code for the List :
<s:List keyUp="lst_selected_files_keyUpHandler(event)" skinClass="styles.skins.ListSkinNoHorizontal"
borderVisible="false"
contentBackgroundColor="#c9c9c9" contentBackgroundAlpha="1"
id="lst_selected_files"
width="100%" height="100%"
alternatingItemColors="[#EAEAEA,#FAFAFA]" color="#000000"
itemRenderer="components.ProgressLabel" dataProvider="{arr_items}" />
<components:RemoveBar nr_of_items="{arr_items.length}" id="cmp_removeBar" hermesRYA="cmp_removeBar_hermesRYAHandler(event)" bottom="-35" width="100%" height="35" />
This is the function that changes the states for the current "to be uploaded file":
protected function uploadNextFile():void
if(uploadingFile!=null) uploadingFile==null;
popup = null;
popup = new ProgressPanel();
lst_selected_files.selectedIndex = currentUploadNr;
current_progressItem = lst_selected_files.dataGroup.getElementAt(currentUploadNr) as ProgressLabel;
current_progressItem.changeState();
lst_selected_files.validateNow();
For some reason the states change ... but the elements aren't visually updated, ... meaning that i still see the label and the progressbar isn't visible :/
anyone ?

This seems to work for me:
<s:Application
    xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:s="library://ns.adobe.com/flex/spark"
    xmlns:mx="library://ns.adobe.com/flex/mx" >
    <s:controlBarContent>
        <s:Button label="test" click="(list1.dataGroup.getElementAt(0) as Object).test()" />
    </s:controlBarContent>
    <s:List id="list1">
        <s:dataProvider>
            <s:ArrayList>
                <fx:Array>
                    [0,1,2]
                </fx:Array>
            </s:ArrayList>
        </s:dataProvider>
        <s:itemRenderer>
            <fx:Component>
                <s:ItemRenderer>
                    <fx:Script>
                        <![CDATA[
                            public function test():void {
                                currentState = 'state2';
                        ]]>
                    </fx:Script>
                    <s:states>
                        <s:State name="state1" />
                        <s:State name="state2" />
                    </s:states>
                    <s:Rect width="50" height="50">
                       <s:fill>
                           <s:SolidColor color.state1="red" color.state2="green" />
                       </s:fill>
                    </s:Rect>
                    <mx:ProgressBar includeIn="state2" />
                </s:ItemRenderer>
            </fx:Component>
        </s:itemRenderer>
    </s:List>
</s:Application>
You will probably want to override getCurrentRendererState() to do this properly tho.  This post demonstrates how to use DataRenderer instead if you would rather: http://flexponential.com/2010/02/07/using-datarenderer-to-add-custom-states-to-a-spark-lis t-renderer/
In general you shouldn't interact with the renderers of a List directly (via getElementAt), but rather by changing the data in the List and building an ItemRenderer that reacts to those changes.  So it would be better if you did something like list1.dataProvider.getItemAt(0).changeState = true and then in your renderer override the data setter to change the state if that variable is set.

Similar Messages

  • Changing states from within a component

    Let's say that I have a TileList that is rendering data in a
    VBox. Eventually the TileList fills up and starts scrolling. I want
    to change states when clicking on item in the TileList.
    I don't want to place the click-attribute in the TileList,
    because it will change states when I am scrolling the list without
    actually selecting anything.
    I want to say click="currentState='state2'" inside the VBox,
    but that does not work because state2 is at the root level, and I
    don't know how to get to the root-level (in lack of a better word)
    from withing the component.
    This is not the proper syntax, so misunderstand me the right
    way here... Is there an equivallence to
    click="currentState='_root.state2'" in mxml?
    Thanks for any suggestions or best practices. I want the easy
    way out.
    This is the general structure...
    <mx:Application>
    <mx:states>
    <mx:State id="state1"/>
    <mx:State id="state2"/>
    <mx:State id="state3"/>
    </mx:states>
    <mx:TileList dataprovider="{...}">
    <mx:itemRenderer>
    <mx:component>
    <mx:VBox id="ClickThisBoxToChangeStates">
    <mx:Image/>
    <mx:Label/>
    </mx:Vbox>
    </mx:component>
    </mx:itemRenderer>
    </mx:TileList>
    </mx:Application>

    Your assumption is right.
    It doesn't work because there is no state2-state defined
    within the mx:component.
    In the documentation about changing states it says that I can
    go from application level and change states within a component;
    like this: click="currentState='mycomponent.anotherstate'" but not
    how I can change a state at application level from within a state.
    When I try, it says (at runtime) that the state is not defined.
    So I don't know why <mx:VBox
    click="currentState='state2'"/> doesn't work.
    I apprechiate your expertese a lot.

  • Change State from Completed to Approved

    Hi All,
    I have a requirement to change the approval task state from Completed to Approved. I am using the standard approval process.
    Please let me know if anyone has done this before.
    Cheers
    Kunal Jain

    Hi,
    Have you tried in the tab " process task assignment" of process task configuration. For the particular task, you need to map " Completed" to approved by double clicking the field mapped to completed. It will give you a list of task names, you need to change it to " approved".
    I hope u have solved your problem already.
    All the best,
    Manila
    Edited by: user2070855 on Mar 14, 2011 6:12 AM

  • Changing state of application from within a custom component

    Hello, I have several custom components all of which are included in the parent application.
    When I try to change state from a custom component, I get an error  saying "undefined state: state name". How do I change the state of the  application from within a custom component ? All the states are defined in the parent application.

    @linrsvp,
    If you are using Flex3 try Application.application.currentState = "somestate";
    If you are using Flex4 try FlexGlobas.topLevelApplication.currentState = "somestate";
    Don't forget to import the corresponding namespaces for the above.
    Thanks,
    Bhasker

  • How to update child record when item from parent record changes

    Hi, I have a master and detail form with two regions on the same page.
    Region one references parent record, one of column in the parent record is also in the child record. And is one to many relation
    between parent record and child record. How can I have the column on the child record updated when the column of the parent record is being modified?
    For exemple; Parent record has two columns : ID and Program.
    Child record has Program, goal# and status. I have two pages established, page 27 and page 28.
    Page 27 list out all programs from parent record, by clicking on edit to a program, it braches to page 28 with program listed as editable field in region one, and mulitple records list in region two from the child record with the same program.
    The problem that I am having is once the program in region one got modified using ApplyMRU, the program in child record did not get updated with the new value and therefore those record become orphan records. I need a way to update all current child records with the new program value.
    Thanks in advance for anyone who can hlep out on this problem.
    Julie
    Edited by: JulieHP on May 24, 2012 4:57 PM

    One Idea is
    If possible create a after update database trigger on the parent table to update the relevant child record.
    Next one
    Create a PL/SQL process on the parent page with process sequence next to ApplyMRU, so when the ApplyMRU is seccessfull it goes not to your process where you can have your update statement

  • Change base view state from a custom component

    I'm pretty new to flex and I'm having a small issue in change the view state from a component.
    My Application have 2 custom components called userlogin and main menu. In the main application page I have userlogin component in one state and the main menu component in another. I'm trying to change the state if the login in successful from user login to main menu. I have the following function written inside the login component.
    private function IsUserLoggedIn(evt:ResultEvent):void
                    if (evt.result.islogin.toString() == "true")
                        currentState = "MainMenu";
                    else
                        Alert.show("Login failed, please try again.", "Login Failed");
    This code worked when I had all the controls in the main page. But then I created components and included them in to components and now when the login is success, its giving the following error.
    ArgumentError: Undefined state 'MainMenu'.
        at mx.core::UIComponent/getState()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UI Component.as:9908]
        at mx.core::UIComponent/findCommonBaseState()[E:\dev\4.0.0\frameworks\projects\framework\src \mx\core\UIComponent.as:9928]
        at mx.core::UIComponent/commitCurrentState()[E:\dev\4.0.0\frameworks\projects\framework\src\ mx\core\UIComponent.as:9750]
        at mx.core::UIComponent/setCurrentState()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\ core\UIComponent.as:9701]
        at mx.core::UIComponent/set currentState()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent.as:6087 ]
        at components::UserLoginForm/__btnSubmit_click()[C:\Projects\WarrantyAutomation\src\componen ts\UserLoginForm.mxml:60]
    I'm sure this has something to do with accessing the states from a custom component, but I do not know how to change the state to the main menu. Please help me with this. Any help is greatly appriciated.

    Hi dasun1981,
    private function IsUserLoggedIn(evt:ResultEvent):void
                    if (evt.result.islogin.toString() == "true")
                        currentState = "MainMenu";
                    else
                        Alert.show("Login failed, please try again.", "Login Failed");
    If I am right the above function is in your userlogin component and the two components "userlogincomponent" and "maincomponent" are in main application file and the states were also defined in main application file.
    But in the function above the currentState refers to the state of the userlogin component and not the main application ...but the states are defined in main application file...that's the reason why the exception was thrown...
    Instead you replace the line in the above function with the below line:
    Application.application.currentState = "MainMenu";
    Please mark it as answer if it helped you.
    Thanks,
    Bhasker Chari

  • Agent cannot change to the requested state from current state

    Hi all,
    I have a new setup using uccx 8 and ccme 8.1 . Everything seems fine exept from randomly agents stuck to a not ready state. When trying to go to a ready state we get the following error "cannot change to the requested state from your current state" . The only option is to log out the agent and then log back in.
    Any ideas?

    Hi there,
    I did the downgrade but no good. After a long search i found what finally the problem is.
    The lines are stuck when there is a trasfer from a non icd dn to an icd dn. Believe it or not this is not supported when the setup uses ccme
    You cannot transfer a call from a common dn to a uccx extension.
    All unsupported features are listed below
    http://www.cisco.com/en/US/docs/voice_ip_comm/cust_contact/contact_center/crs/express_8_0/release/notes/uccx_802_rn.pdf
    Thanks for your time.
    Yannis

  • My billing information is correct however iTunes won't accept it. I have tried changing it to "no" card, my statements from the banks are addressed to the same address. What the **** is going on?!

    My billing information is correct however iTunes won't accept it. I have tried changing it to "no" card, my statements from the banks are addressed to the same address. What the **** is going on?!

    Debit cards already in an account seem to keep working, but many people have reported that when entering or updating a card that debit cards are now rejected, and they're not listed in the accepted payment methods.
    As to your issue, only the iTunes Store can help you with this. I understand the irritation, but please note that the U2 free offer is just a single song, not an entire album, so we're only talking about $.99 if you miss out but still want the track. Not a big deal, in my humble opinion.
    Regards.

  • Flex datagrid itemRenderer with different states

    Hi,
    I have a datagrid with allowMultipleSelection="true" & itemRenderer as my custom component. The custom component have 2 states "NORMAL" & "EXPANDED".
    Now on row selection the renderer should change its state from NORMAL to EXPANDED state. And if I am selecting multiple rows then all the selected rows should be in EXPANDED state.
    As soon as the selection goes the renderer should retain its NORMAL state.
    I am stuck. Please help me out.
    Thanks in advance.

    Use itemclick property of grid and it passes ListEvent  to the method given for itemclick. use selectedindices or selectedcells property in grid to find which are selected and change the states for the renderers of selected rows. U can get the renderer for the current selected row using event.itemRenderer property. Hope this helps.

  • Is it possible to change application state from a component?

    I was wondering if it is possible to change application state from within a custom component and if so, what would the syntax be if I had an application named "zzz" and I wanted to change the app state from "state1" to "state2" from my component?
    Thanks!

    Hi,
    you always have a static class Application.
    Application.application will be the root component. After that you can change it state.
    Application.application.currentState = "state2";
    But it's not the best way to change states. It's better to dispatch events from components and change states in listeners.

  • How to change state of a constraint from DEFERABLE to IMMEDIATE?

    Hi,
    I am runnig 10gR2 and would like to change state of a constraint from
    DEFERABLE to IMMEDIATE without recreating it.
    The change is working at the session level with
    SET CONSTRAINT <constraint name> IMMEDIATE;
    But this is not visible for other users.
    So my question is, if there is any other way to do it, so the change would be visible for every user.
    Here is what I have done:
    CREATE TABLE TEST_TBL
    ID NUMBER
    ALTER TABLE TEST_TBL ADD CONSTRAINT pk_test_tbl PRIMARY KEY(ID)
    INITIALLY DEFERRED DEFERRABLE;
    SQL> INSERT INTO test_tbl VALUES(1);
    1 row created.
    SQL> INSERT INTO test_tbl VALUES(1);
    1 row created.
    SQL> INSERT INTO test_tbl VALUES(1);
    1 row created.
    SQL> COMMIT;
    COMMIT
    ERROR at line 1:
    ORA-02091: transaction rolled back
    ORA-00001: unique constraint (TEST_SCHEMA.PK_TEST_TBL) violated
    The constraint is checked only at commit,
    To change this:
    SQL> SET CONSTRAINT pk_test_tbl IMMEDIATE;
    Constraint set.
    SQL> INSERT INTO test_tbl VALUES(1);
    1 row created.
    SQL> INSERT INTO test_tbl VALUES(1);
    INSERT INTO test_tbl VALUES(1)
    ERROR at line 1:
    ORA-00001: unique constraint (TEST_SCHEMA.PK_TEST_TBL) violated
    But if I would connect with user B, I would be able to do multiple inserts with value 1.
    Thanks

    I am runnig 10gR2 and would like to change state of a constraint from
    DEFERABLE to IMMEDIATE without recreating it.From Oracle Constraints:
    Note: A non-deferrable constraint is generally policed by a unique index (a unique index is created
    unless a suitable index already exists). A deferrable constraint must be policed by a non-unique index
    (as it's possible for a point of time during a transaction for duplicate values to exist). This is why
    it is not possible to alter a constraint from non-deferrable to deferrable. Doing so would require
    Oracle to drop and recreate the index.
    A PK enforces uniqueness procedurally without relying on a unique index. The main advantage
    of a non-unique index is the constraint can be disabled and re-enabled without the index being dropped and recreated.

  • Agents state getting changed automatically from NotReady to Ready

    Agents state getting changed automatically from NotReady to Ready on random position during break time. Can some help me out?
    UCCE version 8.5 

    Hello Ahmad,
    Bug below describes a scenario where the agent is transitioned to the Ready state without manually changing it.
    Also effects 8.5.
    CSCty97770
    Save Bug
    UCCX: Agent Incorrectly Set To Ready After RNA On ICD Extension
    Symptom:
    A Unified Contact Center Express (UCCX) agent may transition to the Ready state without manual intervention.
    Conditions:
    This occurs when, while on a call on the personal line, the agent receives a consult transfer from another agent on the ICD line, does not answer this call and the call is disconnected by the calling agent. When processing this disconnect, the agent state is incorrectly transitioned to Ready even though the call is still in progress ...more
    Details
    Known Affected Releases: (2)
    8.5(1)SU2 | 8.0(2)SU4
    Known Fixed Releases: (1)
    9.0(.96000.398)
    Product: Cisco Unified Contact Center Express
    Hope this helps,
    Please rate helpful posts.
    Thanks.

  • List custom itemRenderer disabled state

    Is there a way to implement a disabled state on a (Spark) List ItemRenderer? I'm developing a List that has a counter on each of it's items. When a user drops that item, the counter decreases. When the item counter reaches 0 the item becomes disabled and the item image becomes black and white.
    I have the disabled state in my custom item renderer but it doens't work. It's state should become "disabled" when I set the enabled property to false.  I've tried to manually set the itemRenderer.currentState to "disabeld" and it becomes "normal" after I click on the list or if I resize the window.
    This is how it should look like (notice that only the orange item is enabled and has colors because his counter still has 9 items):
    I have no idea what's going in the background, can you please point me into the right direction?
    Here's the SWF (source enabled )
    http://dl.dropbox.com/u/6767802/Examples/ListItemDisabledIssue/Flex4ListIssue.html

    I would suggest you to go through the LifeCycle of a component. Those methods will help you manage this.
    In your case you would need a property in you dataProvider that provides the quantity. This property should set a custom property of your component. The custom property should have a setter. Call invalidateProperties() and invalidateDisplayList() to do what you are trying to do in the setter.
    You will have to override commitProperties() and updateDisplayList().

  • Shrink Log file in log shipping and change the database state from Standby to No recovery mode

    Hello all,
    I have configured sql server 2008 R2 log shipping for some databases and I have two issues:
    can I shrink the log file for these databases: If I change the primary database from full to simple and shrink the log file then change it back to full recovery mode the log shipping will fail, I've seen some answers talked about using "No
    Truncate" option, but as I know this option will not affect the log file and it will shrink the data file only.
          I also can't create maintenance to reconfigure the log shipping every time I want to shrink the log file because the database size is huge and it will take time to restore in the DR site, so the reconfiguration
    is not an option :( 
    how can I change the secondary database state from Standby to No recovery mode? I tried to change it from the wizard and wait until the next restore for the transaction log backup, but the job failed and the error was: "the step failed". I need
    to do this to change the mdf and ldf file location for the secondary databases.
    can any one help?
    Thanks in advance,
    Faris ALMasri
    Database Administrator

    1. can I shrink the log file for these databases: If I change the primary database from full to simple and shrink the log file then change it back to full recovery mode the log shipping will fail, I've seen some answers talked about using "No Truncate"
    option, but as I know this option will not affect the log file and it will shrink the data file only.
          I also can't create maintenance to reconfigure the log shipping every time I want to shrink the log file because the database size is huge
    and it will take time to restore in the DR site, so the reconfiguration is not an option :( 
    2. how can I change the secondary database state from Standby to No recovery mode? I tried to change it from the wizard and wait until the next restore for the transaction log backup, but the job failed and the error was: "the step failed". I need to do
    this to change the mdf and ldf file location for the secondary databases.
    can any one help?
    Thanks in advance,
    Faris ALMasri
    Database Administrator
    1. If you change recovery model of database in logshipping to simple and back to full Logshipping will break and logs wont be resored on Secondary server as log chain will be broken.You can shrink log file of primary database but why would you need that
    what is schedule of log backup. Frequent log backup is already taking care of log files why to shrink it and create performance load on system when log file will ultimately grow and since because instant file initilaization is not for Log files it takes time
    to grow and thus slows performace.
    You said you want to shrink as Database size is huge is it huge or does it have lots of free space. dont worry about data file free space it will eventually be utilized by SQL server when more data comes
    2. You are following wrong method changing state to no recovery would not even allow you to run select queries which you can run in Standby mode. Please refer below link to move Secondary data and log files
    http://www.mssqltips.com/sqlservertip/2836/steps-to-move-sql-server-log-shipping-secondary-database-files/
    Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it.
    My TechNet Wiki Articles

  • Remove all entries in sub csv list from parent csv list?

    I have two csv files, one is a complete (parent) list, the other is a sub list. I want to remove all sub-list entires from the parent list. Without manually removing each entry from the parent list one at a time, is there an effecient way to remove all sub list entries from parent list in one simple effort?
    Each list contains email addresses, I want to exclude the sub list from the parent list for the next mailing as they have already completed an action.
    Example:
    Parent list (csv1) has A, B, C, D, E
    Sub list (csv2) has B, D
    How can I remove B & D from Parent list in a concise action?
    Thanks!

    Hi smashart,
    Ian has given you a method that requires manual removal of the unwanted values from the Parent list. My preference would be for a method that constructs a new sub list that includes only the items wanted, but does not affect the original parent list data.
    Like Ian's method, this requires opening both the parent list and the existing sub list of addreses not wanted as separate tables in the same Numbers document.
    Here's an example:
    Two formulas are required.
    Parent::C2, and filled down: =IF(COUNTIF('Sub 1 (have acted)' :: $A,B2)>0,"",MAX($C$1:C1)+1)
    This creates the index shown in column C of Parent. This column may be hidden.
    Sub 2::A2, and filled down: =IF(ROW()-1>MAX(Parent :: $C),"",LOOKUP(ROW()-1,Parent :: $C,Parent :: $B))
    This uses LOOKUP to copy the indexed addresses to Sub 2.
    (Note: Close examination of the addresses in Sub 1 will show a repeated address. As can be seen, this does not affect its removal from the list in Sub 2.
    Regards,
    Barry

Maybe you are looking for

  • My finder is unresponsive

    For the past few days, my finder has been unresponsive. I can't upload, search or open any file. I also can't connect to any wifi other than the ones recognized by by macbook. Nor can I see how much battery is left. I want to reformat my macbook but

  • IPod Touch wont download podcasts anymore

    Up until last Friday I would download my daily podcasts directly to my iPod Touch(Third Generation) via wifi connection by clicking on the "Get More Episodes" link at the bottom of each podcast list in my music folder on my ipod. For some reason it h

  • Resolution changing on its own

    Hello, I have a 2003 20" Cinema clear acrylic display hooked up to my MacPro and it's been working fine for the last year. Over the last couple of weeks the display resolution has been changing to a smaller resolution by itself. I'll be away from the

  • Manual Payroll cheques post to the GL

    Dear Gurus! Is there a check box or what the configuration required might be to change the way that Manual Payroll cheques post to the GL? Currently if more than one manual cheque is posted they are posted in total amount to the bank GL, not individu

  • HT1688 can I use locked iphone5 in china

    Can I use iphone5 in China? locked one with AT&T