Set data function

hi folks,
i'm new to flex and that is why i don't know when the set data function of item renderer is called. means what causes the call for set data function of item renderer?
i inherited a flex application (the developer left) and i am wondering why the set data function of one item renderer is called when an item of the item renderer was clicked but the set data function of another item renderer is called just one time (when the view is created) but never again even if an item of the item renderer was clicked.
so please can someone explain me or mention a good ressource for reading about how it works?

Whenever data changes in some way, for example when the dataprovider is changed, the set data function is called automatically.
Some tips:
1. Make sure the dataprovider is bound (<s:List dataprovider="{myDataCollection}"/>
2. If you change the dataprovider, call the refresh() function (like when the dataprovider is a IListCollectionView)
3. override the set data function in your itemRenderer to do additional things there.
Hope this helps
Dany

Similar Messages

  • Problem overloading "set data" function on Button DataGrid Renderer

    Hi all, I'm hoping this is something simple.
    I have a class that extends mx.controls.Button and implements mx.core.IDataRenderer.  I need to set the button icon whenever the Data property is set from the DataGrid.  My problem is that my overloaded set/get Data function are never called (I've stepped through the code in debug).  Instead the set/get functions in Container.as (Flex 3.4 SDK) get called.
    Here's the basics code:
    exportButtonRenderer.as
    package controls
        import flash.events.Event;
        import flash.events.MouseEvent;
        import mx.controls.Button;   
        import mx.core.IDataRenderer;
        import mx.controls.dataGridClasses.DataGridListData;   
        import mx.controls.listClasses.BaseListData;
        import mx.events.FlexEvent;
        import mx.controls.Alert;
        import model.descriptors.compDescriptor;
        import events.exportClickedEvent;   
        public class exportButtonRenderer extends Button implements IDataRenderer   
            //    embed your icons
            [Embed(source='/assets/icons/export.png')]
            [Bindable]
            public static var imageExport:Class;
            [Embed(source='/assets/icons/blank.png')]
            [Bindable]
            public static var imageBlank:Class;
            public function exportButtonRenderer()
                super();
            private var _listData:DataGridListData;
            override public function get listData():BaseListData
                return _listData;
            override public function set listData(value:BaseListData):void
                _listData = DataGridListData(value);
            private var _data:Object;       
            override public function get data():Object
                return _data;
            override public function set data(value:Object):void
                _data = value;
            override protected function clickHandler(event:MouseEvent):void
                super.clickHandler(event);   
    Now I know I'm using the Flexlib TreeGrid and not a standard DataGrid but when I trace through all the code all code firing the set/get functions is coming from the DataGrid anyway.
    Here's the my Grid def in my main app mxml:
    Header 1
    <flexlib:TreeGrid
            id="MKTXGrid"
            dragEnabled="false" sortableColumns="false" showRoot="false"
            disclosureClosedIcon="@Embed(source='/assets/icons/arrow_right.png')"
            disclosureOpenIcon="@Embed(source='/assets/icons/arrow_down.png')"
            folderOpenIcon="@Embed(source='/assets/icons/psd.png')"
            folderClosedIcon="@Embed(source='/assets/icons/psd.png')"       
            click="MKTXGrid_clickHandler(event)"
             doubleClickEnabled="true" doubleClick="MKTXGrid_doubleClickHandler(event)" left="0" right="0" top="0" bottom="16">
        <flexlib:columns>
                <flexlib:TreeGridColumn dataField="Name" headerText = "Name" minWidth="200" width="200" editable="true"/>
                <mx:DataGridColumn dataField="ExportName" headerText = "Export Name"/>
                <mx:DataGridColumn dataField="Export" headerText = "Export" width="50" minWidth="20" resizable="false">
                 <mx:itemRenderer>
                    <mx:Component>
                        <mx:Box horizontalAlign="center" width="100%" verticalScrollPolicy="off" horizontalScrollPolicy="off">
                            <controls:exportButtonRenderer label="Export" icon="@Embed(source='assets/icons/export.png')" width="12" height="12" useHandCursor="true">                        
                                <controls:click>
                                    <![CDATA[
                                        import events.exportClickedEvent;
                                        var e:exportClickedEvent = new exportClickedEvent();
                                        e.itemData = data;
                                        dispatchEvent(e);
                                    ]]>
                                </controls:click>
                            </controls:exportButtonRenderer>
                        </mx:Box>
                    </mx:Component>
                </mx:itemRenderer>
                </mx:DataGridColumn>
            </flexlib:columns>
        </flexlib:TreeGrid>
    Nothing too special going on.
    I know this can be done, I've seen examples in the SDK:
    http://opensource.adobe.com/svn/opensource/durango/trunk/ExternalFlexTools/com/dougmccune/ containers/accordionClasses/AccordionHeader.as
    By the way I've stepped through the code of the TreeGridItemRenderer class in Flexlib which works correctly and the class def starts like this:
    TreeGridItemRenderer.as
    import flash.display.DisplayObject;
    import flash.display.InteractiveObject;
    import flash.display.Shape;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.geom.Point;
    import flash.geom.Rectangle;
    import flexlib.controls.TreeGrid;
    import mx.controls.Image;
    import mx.controls.dataGridClasses.DataGridListData;
    import mx.controls.listClasses.BaseListData;
    import mx.controls.listClasses.IDropInListItemRenderer;
    import mx.controls.listClasses.IListItemRenderer;
    import mx.core.IDataRenderer;
    import mx.core.IFlexDisplayObject;
    import mx.core.IToolTip;
    import mx.core.SpriteAsset;
    import mx.core.UIComponent;
    import mx.core.UITextField;
    import mx.events.FlexEvent;
    import mx.events.ToolTipEvent;
    import mx.events.TreeEvent;
    import mx.managers.ILayoutManagerClient;
    import mx.styles.IStyleClient;
    public class TreeGridItemRenderer extends UIComponent
                                      implements IDataRenderer,
                                                   IDropInListItemRenderer,
                                                 ILayoutManagerClient,
                                                   IListItemRenderer
    Any help would be great!

    That's because you put your component in a Box.  The DataGrid is setting the Box's .data property and no code is setting the one on your component.  You shouldn't really need Box.  You can override updateDisplayList to center your Button instead.
    Alex Harui
    Flex SDK Developer
    Adobe Systems Inc.
    Blog: http://blogs.adobe.com/aharui

  • Javascript set date function sequence issue

    This is a javascript date error that occurs in FireFox, Chrome and IE.
    In setting the date using utc functions the order in which the functions are used can cause the wrong date set be set.
    var d = new Date();
    d.setUTCFullYear(2012,1,26);
    correctly sets the date:
    Sun Feb 26 2012 10:10:33 GMT-0500 (Eastern Standard Time)
    var d = new Date();
    d.setUTCFullYear( 2012 );
    d.setUTCMonth( 1 );
    d.setUTCDate( 26 );
    incorrectly sets the date:
    Mon Mar 26 2012 11:10:33 GMT-0400 (Eastern Daylight Time)
    var d = new Date();
    d.setUTCDate( 26 );
    d.setUTCMonth( 1 );
    d.setUTCFullYear( 2012 );
    correctly sets the date:
    Sun Feb 26 2012 10:10:33 GMT-0500 (Eastern Standard Time)
    It appears the full date isn't being used to re-validate/calc the date upon setting single utc parms.
    Thanks.
    This happens Windows 7, NOOK...

    Short answer; no, doesn't happen Apr 1.
    <br/>Longer answer; I set up a page to loop through everyday of a given month.
    <br/>(http://itriware.com/lab/test/datetest.html)
    <br/>Changing the machine date results in:
    * md:30-Mar - no good for the month of Feb.
    * md:31-Mar - no good for the months: Feb, Apr, Jun, Sep, Nov.
    * md:01-Apr - ok
    * md:30-Apr - no good for the month of Feb.
    * md:31-May - no good for the months: Feb, Apr, Jun, Sep, Nov.
    (md=machine date)
    Seems to be an end of the month issue, depending on the sequence of setting the utc parms, the month rolls over but isn't adjusted back when setting the next parm...sometimes.
    After thinking about it;
    Seems that if the machine day of month is greater than the # of days in the requested month it fails, hence feb always fails and only requested months with 30 days fail when the machine date is the 31st. In the sequence setUTCFullYear, setUTCMonth, setUTCDate.

  • Flex override public function set data

    Hi,
    I have a datagrid with itemRenderer in datagridcolumn as my custom component(c1). I am getting the dataprovider data in custom component by overriding the set data function, it is fine. But now my custom component(c1) is also having another custom component(c2).
    Now the doubt is - how to get the dataprovider data in c2 component?
    Thanks in advance.

    Create a property with name custom_data in component c2
    set the value of  _customData in c2 object created in c1 with the data u get in c1 in commitProperties method of c1.
    c2.customData = this.data;

  • How to make sure override public function set data(item:Object) is called on vertical scroll

    Hi
    I am facing an issue with my datagrid with renderers on all its columns.I need to enable or disable the render components based on values in different columns in the row.Its works fine in most of the places .But in some places which is not visible without the scroll,it seems the set data function is not called,because of which the component will be enabled when it has to be disabled.How do i ensure it works fine all the time.
    Regards
    Sidd

    The set data is probably being called.   Keep in mind that renderers are recycled so the enabled/disabled state must be fully derived from the row's data.
    Alex Harui
    Flex SDK Developer
    Adobe Systems Inc.
    Blog: http://blogs.adobe.com/aharui

  • Set Data

    Hi
    1. I am trying to use the SET data functionality from the System- Userprofile.
    The data is getting"SET" but next time if i execute the same transaction then i dont see the set value.
    example: 1. In Tcode VA01 for me the plan and the sales area doesnt change so i am planning to use the SET data.
                   2. The data gets set only temporarily but next time when iput va01 again asking me for reentering.
    kindly let mek now your valuable inputs to solve this..
    reg
    satheesh

    Sorry.  The link given to me by another in this forum:
    http://support.apple.com/manuals/#appleremotedesktop
    first link is v2.2.  I thought the most recent would show up at the top...
    I should have looked at the bottom 

  • Loss style when overriding the function 'set data' for a TileList

    Hi!
    In a TileList, I set the itemRenderer for a components from
    where I override the function set data like in this example:
    but, by doing this, I'm loosing all the built-in CSS
    behavior. The onMouseOver effect the change the backgroundColor and
    the hand pointer. I try to set it programmatically but without
    success.
    An idea?
    Thank you

    "FlexBin" <[email protected]> wrote in
    message
    news:gdaj4r$noj$[email protected]..
    > Hi!
    >
    > In a TileList, I set the itemRenderer for a components
    from where I
    > override
    > the function set data like in this example:
    >
    > but, by doing this, I'm loosing all the built-in CSS
    behavior. The
    > onMouseOver
    > effect the change the backgroundColor and the hand
    pointer. I try to set
    > it
    > programmatically but without success.
    >
    > An idea?
    >
    > Thank you
    >
    > public override function set data(value:Object):void
    > {
    > var xml:XML = new XML(value);
    >
    > if(this.backgroundIconName != null &&
    > this.ico != null &&
    > this.labelText != null) {
    >
    > if(xml.backgroundIconName != "") {
    >
    > this.backgroundIconName.source = "assets/" +
    xml.backgroundIconName;
    > }
    >
    > this.backgroundIconName.visible =
    (xml.backgroundIconName != "");
    >
    > this.ico.source = "assets/" + xml.iconName;
    > this.ico.width = Number(xml.width);
    > this.ico.height = Number(xml.height);
    >
    > this.labelText.text =
    resourceManager.getString('myResources',
    > xml.label);
    > }
    >
    > if(xml.@available == 'false')
    > {
    > this.enabled = false;
    > }
    > }
    There are examples of how to properly implement this kind of
    functionality
    in the itemRenderers here:
    http://flexdiary.blogspot.com/2008/09/groupingcollection-example-featuring.html
    http://flexdiary.blogspot.com/2008/09/extended-datagrid-with-stylefunction.html

  • Hi, My ipad has been stolen and I set up the erase data function in i cloud "find my device". I then changed my mind and wanted to change this to locate my device

    Hi, My ipad has been stolen and I set up the erase data function in i cloud "find my device". I then changed my mind and wanted to change this to locate my device rather. When I deleted the "erase" option it removed my ipad from the find my device list. Can I restore it back onto the list?

    Once a wipe is sent, it cannot be stopped. You will not be able to track your iPad after that.

  • How to get the "last changed by" for a set of function modules?

    How to get the "last changed by" for a set of function modules?
    is there any table to get it??

    See [this|Re: Date of creation of function module] I posted earlier.
    >TFDIR will give you the name of the function group program and the include number.
    >E.g. SAPLZFUNCGROUP Include 01.
    >From this you can construct the include name: LZFUNCGROUPU01.
    >You can look this up in TRDIR to find the creation date (CDAT) of the function module.
    In your case, you need unam and udat.
    matt

  • Print a DayName without using Date functions

    Hi,
    I have an assignment like without using any date functions i should print a calendar.
    Below is the code without using any datefunctions like dateadd, datediff, datename a calendar has been generated for month and year entered. I want a week name for the dates like sunday ... monday etc. 
    I can take any date from calendar as reference  and calculate based on that date.
    ex: today is 2/20/2014 thursday . Next 7days again will be thursday, same way before 7days will be thursday.
    I need to loop in below procedure and get weekname. 
    Plz help in the code,
    I am using SQL server 2008
    IF OBJECT_ID ('dbo.Calendar1') IS NOT NULL
         DROP PROCEDURE dbo.Calendar1
    GO
    CREATE  PROCEDURE [dbo].Calendar1 --4,1991
       @month int,
       @Year  int
     AS  
     BEGIN
     declare 
     @startdateofMonthYear date,
     @EnddateofMonthYear Date
    Set @startdateofMonthYear=(Select cast(@Year as varchar(4)) +'-'+Right('00'+Cast(@month as varchar(2)),2) +'-'+'01')
    Set @EnddateofMonthYear = (SELECT case when @month IN (1,3,5,7,8,10,12) then cast(@Year as varchar(4)) +'-'+Right('00'+Cast(@month as varchar(2)),2) +'-'+'31'
    when @month IN(4,6,9,11) then cast(@Year as varchar(4)) +'-'+Right('00'+Cast(@month as varchar(2)),2) +'-'+'30'
    else  cast(@Year as varchar(4)) +'-'+Right('00'+Cast(@month as varchar(2)),2) +'-'+(CASE WHEN (@YEAR % 4 = 0 AND @YEAR % 100 <> 0) OR @YEAR % 400 = 0 THEN '29' else '28' End) 
    End) 
    ;WITH CTE_DatesTable
    AS
    Select 1 daysint, Cast(SUBSTRING(cast(@startdateofMonthYear as varchar(20)),1,7) + '-'+CAST(1 as varchar(2)) as DATE) Calendardates
    UNION ALL
    SELECT   daysint+1,Cast(SUBSTRING(cast(@startdateofMonthYear as varchar(20)),1,7) + '-'+CAST(daysint+1 as varchar(2)) as DATE) Calendardates
    FROM CTE_DatesTable
    WHERE  daysint<= 
    (SELECT case when @month IN (1,3,5,7,8,10,12) then 31
    when @month IN(4,6,9,11) then 30
    else  (CASE WHEN (@YEAR % 4 = 0 AND @YEAR % 100 <> 0) OR @YEAR % 400 = 0 THEN 29 else 28 End) 
    End)-1
    Select 
    [DWDateKey]=Calendardates,
    [DayDate]=daysint,
    [MonthNumber]=@Month,
    [MonthName]=Case when @month = 1 then 'January'
     when @month  = 2 then 'February'
     when @month  = 3 then 'March'
     when @month  = 4 then 'April'
     when @month  = 5 then 'May'
     when @month  = 6 then 'June'
     when @month  = 7 then 'July'
     when @month  = 8 then 'August'
     when @month  = 9 then 'September'
     when @month  = 10 then 'October'
     when @month  = 11 then 'November'
     when @month  = 12 then 'December' 
    End,
    [Year]=@Year
    From CTE_DatesTable
    END
    bhavana

    In the above code, where do i pass the year and month?
    (Select 2000 YearID
    Union All
    Select YearID +1 From cte where YearID <2100
     In above condition from 2000 year its displaying.
    If i want in 90's year , Day name will not be correct.
    Deepa

  • How to set Oracle function as a PreparedStatement parameter?

    Hi all,
    I was wondering if it is possible to use Oracle function as a PreparedStatement parameter? For example:
    PreparedStatement pstmt = new PreparedStatement("update table set date=? where ...");
    pstmt.set???(1, sysdate);I can put the function in the sql directly of course, but the parameter is depending on some condition. Any idea is greatly appreciated.
    Joey

    First, sysdate isn't a function, it's really a pseudo-value.
    Second, it doesn't exist on the Java side, therefore it can't be bound via a set statement.
    The correct and standard way is to put it in the SQL; if the use of sysdate is conditional, you can:
    1) embed the conditionality in the SQL, e.g.:
    PreparedStatement pstmt = new PreparedStatement("update table set date= decode( ?, 0, ?, 1, sysdate, sysdate) where ...");2) for more complex conditionality, define a custom function and embed that in your SQL
    3) do it on the Java side and use more than one preparedstatement

  • "RT Set date and time" does not set seconds in UTC mode

    Hallo,
    I tried to set the time on my cRio 9012 with the function settimeUTC which is used by the "Set Date and Time" vi. But the seconds I enter are ADDED to the current time and not set as new value.
    Even the vi shows this behaviour: I set up a vi in which the time is set in a loop (100ms delay) and read again. When I set local time the clock stops (as expected) but when I set the UTC time the seconds keep on running...
    Can anybody help me with that problem???
    Thanks
    Florian
    Solved!
    Go to Solution.

    Hi Andreas,
    well it does not matter if I set a time zone in the MAX or not. In my example I was working on UTC + 0 but even when I set it to my local time (UTC + 1) I get the same behaviour modified by one hour.
    My LabView Version is 8.5. In in the MAX under Software-> LabView-RealTime it says that I am using 8.5.0.
    I suspect  that the settime.out which is installed on the cRio is probably the root of the problem as VxWorks itself does not offer a function (at least I did not find one) to convert from broken down system time to system time in seconds. There only exist one to convert from broken down local time to system time in seconds ( mktime() ). The reverse function is available for both cases: gmtime() and localtime(). I also did not find a way to find out the offset of the local time. So I have to use the library function settimeUTC() from settime.out.
    As I offered I can send you the settime.out file from my cRio for reference or maybe you can tell me how to find out what the version of the file is. It seems not to be an ELF file as I looked inside it to find some timestamp or version info...
    Thanks so far 
    Florian

  • Use a Parameter or Formula in the Date() function

    I am trying to filter a result set utilizing the Date() function.  I am trying to get all of the data between June 1st of a given year, and a parameterized date.  Here is the formula
    {ReportStatic.rpsActualSaleDate} >= Date({@fPrevioustoLastYear}, 7, 1)
    and {ReportStatic.rpsActualSaleDate} < DateAdd("yyyy", -2, {?pDateEnd})
    and {ReportStatic.rpsSaleStatus} = 1
    The value of fPrevioustoLastYear is '2008'
    The report is returning 0 records.  I think it is because the Date() function isn't recognizing the formula (fPrevioustoLastYear) as a valid input.  However when I "Save and close" the formula editor doesn't find any problems with the formula.
    What should I be doing differently?

    If {@fPreviousToLastYear} is in fact 2008, I don't see an issue (with the possible exception that it should be a number, not a string; convert with CInt()).  Please post your formula for that field.
    Also, I have to ask what the value of {?pDateEnd} is.  If it's like today, no records will fit the criteria because you'd be checking if the date was between 7/1/2008 and 3/29/2008 (you're subtracting 2 years from the parameter), which is a null set.
    HTH,
    Carl

  • Setting date in prepared statement

    I am using
    preparesStatement.setDate(param1,findAuditSearchDTO.getStgAuditGeneral().getAuditBeginDate());
    I am wondering setting date this way will slow down the query?
    should I use preparesStatement.setString where I can call to_date function or the above code will work fine and not make any difference in performance ?

    user11138293 wrote:
    I am using
    preparesStatement.setDate(param1,findAuditSearchDTO.getStgAuditGeneral().getAuditBeginDate());
    I am wondering setting date this way will slow down the query? No. And even if it did, it would still be the right way to do it. The main point of using PreparedStatement is so that you can use the correct types in your Java code and don't have to worry about formatting and such.
    As far as performance is concerned, any difference introduced by type conversion will be minuscule compared to roundtrip I/O between you and the DB and any disk I/O the DB needs to do. And of course, if it's a DATE column on the DB (which it had better be, if it's representing a date), then the DB would just have to convert the string to a date anyway.
    Focus on good design, and on using data structures, algorithms, classes, and methods, that are appropriate to what you're trying to do and that lead to easy-to-understand code.

  • How can I get a PHP include to update automatically after a set date?

    Hi guys,
    I maintain a number of website for sports athletes and on their websites I have an include for their next event - just a small PHP file with when and where the next event is.
    After each event I have to manually update the include to the clients' next event which is a bit of a pain and quite time-consuming.
    Is there any way I can set up the include script to automatically update with a different file to include after a set date?
    Or, even better, can I set up the include itself to display the updated content after a specific date?
    This is what the include contains...
    <img class="event" src="/images/eventPicture.png" />
    <p class="nextEvent">Location<br />
    Series<br />
    1-3 January 2013</p>
    Thank you very much and I hope to hear from you!
    SM

    Its easier than setting up a database...I've been dabbling. You will still need to use server-side language like php.
    First establish the date by adding the get date function to the page:
    <?php
    $date = date('d-F-Y');
    ?>
    Then add the below bit of php in the position where you want the 'include' to appear. (so if on the 19th of April you want event_3.php to appear:
    <?php
    if ($date == "19-April-2013") { ?>
    <?php include ('event_3.php')?>
    <?php } ?>
    This isnt economical for many event dates but if you have a few it will do as a solution.
    It's not great because you would need to add as below, changing the include on the date you want it to show which will replace the previous event.
    <?php
    if ($date == "19-April-2013") { ?>
    <?php include ('event_3.php')?>
    <?php } ?>
    <?php
    if ($date == "30-May-2013") { ?>
    <?php include ('event_4.php')?>
    <?php } ?>
    <?php
    if ($date == "4-June-2013") { ?>
    <?php include ('event_5.php')?>
    <?php } ?>

Maybe you are looking for