Items in Tree control move around when data is submitted using custom ItemRenderer

I'm working on a Tree control with an XMLListCollection as
its dataProvider.
The dataProvider has information looking like this :
quote:
<?xml version='1.0' encoding='utf-8'?>
<INFO>
<FIELD label="STR_USER_NAME"
type="text"
value=""
>
</FIELD>
<FIELD label="STR_USER_EMAIL"
type="text"
value=""
>
</FIELD>
<FIELD label="STR_OPTIONAL"
type="branch"
value="0"
>
<FIELD label="STR_USER_ADDRESS"
type="text"
value=""
>
</FIELD>
<FIELD label="STR_USER_POSTAL_CODE"
type="text"
value=""
>
</FIELD>
</FIELD>
</INFO>
So in the Tree control I'd like the information to show up
with a label and
an
editable textbox for each item :
[Label] [textbox]
To do this I made a tree like this :
quote:
<mx:Tree id="userTree"
editable="true"
rendererIsEditor="true"
editorDataField="curVal"
itemRenderer="{new ClassFactory(ItemRendererUser)}"
itemEditEnd="e_ProcessData(event);"
dataDescriptor="{new DataDescriptorUsers()}"
showRoot="false"
verticalScrollPolicy="{ScrollPolicy.AUTO}"
/>
where the e_ProcessData() function looks like this (I used
http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/js/html/wwhelp.htm?href=c
elleditor_073_16.html#202105 as a guide) :
quote:
public function e_ProcessData(event:ListEvent):void
event.preventDefault();
userTree.editedItemRenderer.data.@value =
ItemRendererUsers(event.currentTarget.itemEditorInstance).curVal;
userTree.destroyItemEditor();
userTree.dataProvider.notifyItemUpdate(userTree.editedItemRenderer);
} // END OF e_ProcessData()
I attached the rest of the files because they're a little
bit longer.
When I run the program, the data shows up fine when it is
initialized the
very
first time, and I made a test button that just dumps the
contents of the
dataProvider in a trace statement to verify that the data has
been set
properly.
The problem I've run into is whenever the textfield is
edited, the item
that
I've selected jumps around the list.
For example, if I edit the item "STR_USER_NAME" after I
finish the edit, it
will move from the very first position in the Tree to the
bottom of the
Tree.
I traced the contents of the dataProvider and the
dataProvider structure
stays
the same, with the "STR_USER_NAME" at the top, but if I look
at the flex app
in
the web browser, its position is at the bottom of the Tree.
This happens for every other item I try to edit... I read in
the
documentation
that the ItemRenderers are recycled, so it means I should be
checking to
make
sure the initial states are covered, but I'm not sure how
this affects my
application.
Can anyone help me out with this ? Its very confusing - I've
tried making
an
ItemRenderer using pure actionscript, mxml and the
combination you see in
this
example and I always end up with the same behaviour - So I
must be missing
something critical...
// ItemRendererUsers.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="
http://www.adobe.com/2006/mxml"
verticalScrollPolicy="{ScrollPolicy.OFF}"
horizontalScrollPolicy="{ScrollPolicy.OFF}"
creationComplete="initItemRendererUsers();"
>
From my FAQ:
Q: I've created a custom itemRenderer component to use in a
List
based component (Datagrid, TileList, HorizontalList, etc.).
When my List
first displays, everything looks fine, but when I scroll it
or change the
dataProvider, some of the itemRenderers show values or
formatting that
aren't right. How do I fix this?
A: List-based components don't draw a renderer for every item
in the
dataProvider. Instead, they create enough to display what is
on screen now,
plus one or two more waiting in the wings. This means they
recycle the
renderers rather than creating new ones when you change
dataProvider or
scroll up and down. When you use a creationComplete event to
set up the
itemRenderer, that event doesn't happen again when the
renderer is used for
a different set of data. The solution to this is to override
the set data
protected function that most components have.
For more information, check out the following resources:
http://www.adobe.com/devnet/flex/articles/itemrenderers_pt1.html?devcon=f1
http://blogs.adobe.com/aharui/2007/03/thinking_about_item_renderers_1.html
Please note, I post this FAQ weekly, and you can find a
permanent copy of it
here
http://www.magnoliamultimedia.com/flex_examples/Amys_Flex_FAQ.pdf

"peterh8234" <[email protected]> wrote in
message
news:gaqttd$kft$[email protected]..
> Yes - the set and get functions are listed down below.
But the quirky
> behaviour
> is the same regardless of whether I override the set and
get functions or
> not.
>
> I noticed there was another variable called listData -
should I be using
> that
> one or the data variable to read and write to the
dataProvider ?
>
> // _data
> [Bindable] public var _data:Object;
> [Bindable("dataChange")]
> //
> override public function get data():Object
> {
> trace('[ItemRendererDefault.GET data()] called for {' +
> _data.attribute("label") + '}.');
> return _data;
> } // END OF get data()
>
> //
> override public function set data(value:Object):void
> {
> _data.@value = inputText.text;
> trace('[ItemRendererDefault.SET data()] called for {' +
> _data.attribute("label") + '}.');
>
> invalidateProperties();
> } // END OF set data()
Your set data needs to set a flag that gets picked up in
commitProperties()
and does your thing that you were doing before in
creationComplete. You
should see examples of this in the links I posted. Instead of
this:
_data.@value = inputText.text;
you should look at implementing IDropInListItemRenderer,
which will allow
you to dynamically determine which field to look at, instead
of hardcoding
it. You also might wind up overwriting the stored value with
a null value
when the List passes the stored value in. I'd encourage you
to really go
through those links I posted and make sure you understand
what they're
saying. The itemRenderer life cycle is one of the hardest
things to
understand, but once you understand it, it makes many things
in Flex much
easier. It's worth investing the time.

Similar Messages

  • Tree control - How to get the full path of selected Item in tree control

    I am Flex newbie. When the user clicks the particular item in
    the tree control I just wanted to get it name along with it's full
    parent.
    Here is my XML
    var dirXML:XML=<root basename="/home/tcegrid">
    <Directories>
    <Dir Name=".autosave" />
    <Dir Name=".emacs.d" />
    <Dir Name="AnsysDistributed">
    <Dir Name="opt"/>
    <Dir Name="root" />
    </Dir>
    <Dir Name="postgres"/>
    <Dir Name="FineTurbo"/>
    <Directories>
    </root>
    The above XML is data provider for Tree control. When the
    user clicks the Dir Name called opt. I wanted it absolute path in
    XML. say Directories.Dir.Dir.@Name is opt
    Can any one tell me how to get this?

    "Thamizhannal" <[email protected]> wrote in
    message
    news:gam9q8$4es$[email protected]..
    >I am Flex newbie. When the user clicks the particular
    item in the tree
    >control
    > I just wanted to get it name along with it's full
    parent.
    > Here is my XML
    > var dirXML:XML=<root basename="/home/tcegrid">
    > <Directories>
    > <Dir Name=".autosave" />
    > <Dir Name=".emacs.d" />
    > <Dir Name="AnsysDistributed">
    > <Dir Name="opt"/>
    > <Dir Name="root" />
    > </Dir>
    > <Dir Name="postgres"/>
    > <Dir Name="FineTurbo"/>
    > <Directories>
    > </root>
    >
    > The above XML is data provider for Tree control. When
    the user clicks the
    > Dir
    > Name called opt. I wanted it absolute path in XML. say
    > Directories.Dir.Dir.@Name is opt
    > Can any one tell me how to get this?
    loop until the parent() property of the XML node is empty.
    HTH;
    Amy

  • Pages zoom and move around when I attempt to write on them

    New to iPad. Primary use for which I purchased it was to read and annote pdfs. I've purchased PF Expert, and am extremely pleased with it so far---not only the app, but the support provided by the developers.
    My issue may just be due to my lack of experience with the iPad. It is that when I attempt to highlight a document in PDF Expert using a stylus, the page zooms in and out and moves around. This makes highlighting pretty inconvenient. I would like pages to remain fixed, the way a piece of paper would while I'm writing on it. I have wrist protection turned on in PDF Expert.
    Is there something I'm missing regarding technique? Or is there something I can set somewhere that will prevent this form happening.
    Thanks,
    Eric Weir

    anyone fix the problem yet?I cleared my cookies and that didnt work.

  • Editable Items in Tree Control

    Hi all,
           i ve the following req. :
       i need a tree control which has its items under nodes
    to be displayed in editable mode...is it possible...how?
    Can i use  method  item_set_editable of class CL_GUI_COLUMN_TREE???
    kindly reply asap...
    Thanks
    vijay.

    The cells in ALV tree are not editable! It is only used for display.

  • Why do my photos move around when I save an image from email so difficult to locate the new saved image

    My photos move around randomly after I save an image from email can't locate picture easily with 1000 photos on iPad please help

    I believe the default is for them to order themselves in 'date taken' order. Unfortunately there's nothing you can do to change that. It's the default in the photos app and users can't change it. You can try looking for a third party photo app that may have more functionality. Afraid I can't recommend any since I've never looked for them but I'm sure someone can.

  • AS 3.0 & WebService & Tree control Bind to hierarchical data?

    What is the trick to get the results of a call to a
    webservice that returns a hierarchical XML SOAP document to map
    directly to a Tree Control's dataProvider property?
    In the debugger, I can see that lastResult is an ObjectProxy
    which has a couple of properties and one of them is an
    ArrayCollection as I expect. However, I can't figure out how to use
    this result with a Tree control and the dataProvider property so
    that I can navigate thru the hierarchy returned.
    TIA
    George

    Yeah this is using the embedded scripting. I need to change this to show the final sql vs. the script that is being used.
    -kris

  • Generated file becomes empty when date parameters are used

    Hi,
    I have a concurrent program which when run should generate a file. The From and To date parameters make use of a value set (FND_STANDARD_DATE_REQUIRED) whose format type is the 'standard date' and maximum size is 11.
    When I run the program in APPS, the format for the FROM and TO date parameters I use is 'DD-MON-YYYY'.
    The package which is being called by this program has this in the select statement: and ct.trx_date BETWEEN p_begin_date AND p_end_date
    ct.trx_date field type is DATE
    Each time I comment out this part of the select statement then compile the package and run the program, I am able to generate the file with the expected records. But when I use this part of the select statement, the genereted file is empty.

    Yes, I expect 12 records to be in the file.
    Am just not sure if the problem has something to do with the data type being passed. In the package that is being called, the from and to date parameters in the procedure are 'VARCHAR2'. While in apps, the concurrent program's from and to date parameters were assigned a value set whose custom type is 'CURRENT DATE' with format 'DD-MON-YYYY'.

  • Detecting when exception was thrown using custom class loader

    Hello all,
    I would like to implement the solution described here - http://stackoverflow.com/questions/75218/how-can-i-detect-when-an-exceptions-been-thrown-globally-in-java - that uses custom class loader in order to detect when an Exeption thrown somewhere in the JVM hosting my app, please note that exceptions might be thrown from 3rd party jars the app is using. So, thanks to help I got from another post, I've managed to code the custom class loader. My question is how can the class loader wrap the original exception, as the methods in ClassLoader deals with classes, not instances. So where should I set the original exception?
    Thanks!
    Edited by: user9355666 on Sep 28, 2010 10:48 PM

    user9355666 wrote:
    I think I'm missing something fundumental, forgive me for being slow...
    This is what I did so far. For the exception wrapper I made a simple class extens Exception that recieve Exception in its ctor and store it. I also subclassed ClassLoader and override its loadClass(). I've registered it as the system classloader. My thinking was to check in that point that if the requested class is instance of Exception and if yes, returning my wrapper class wrapping this exception. But, since loadClass() return class, how can I set in the wrapper the original exception?
    In addition, let's say 2 different places in the code throws NPE, to my understanding the classloader will load NPE only once, so how throwing the NPE in the second time can be detected?you are missing a key point. you should creating a custom implementation of the NPE class which hooks into your detection code in its constructor. from that point forward, anytime any NPE (which is your custom class) is constructed, you can detect it.

  • Siena - Gallery control behaving differently when data is filtered?

    I have a gallery control populated by a dataset that contains images and text. In my app I have two dropdowns that I use to filter the contents of the gallery. When the gallery is showing 'all' (nothing filtered out, selecting an image in the gallery
    results in the selected item moving to the top of the gallery. However, when the dataset is filtered, I get a different result:
    1. If the dataset it small enough to be visible on the screen, the selected image stays in place and is visible
    2. If the dataset is bigger than what can be viewed on the screen, selecting an image in the gallery results in the selected image being scrolled off screen
    Any ideas on how to program the selection behavior to make it consistent?

    Also, here is the filter I am applying to the dataset:
    If(Dropdown_Location_Filter!Selected!Value="ALL", BUSINESS_LIST_1,Filter(BUSINESS_LIST_1, NEIGHBORHOOD=Dropdown_Location_Filter!Selected!Value))

  • Clips move around when I edit out a section

    I am sure many of you know what I am trying to ask, it's just difficult for me to describe. When I edit out a section of one clip, all of the clips move over to fill in that space, that's not what I want to happen..I want everything to stay where it is and there to be a blank space where I just edited. I can get an animated part synced up perfect, decide to change one thing and the whole thing is messed up!
    What am I missing here? Help?
    Thanks in advance...
    peace, pride & respect,
    Chris

    You aren't missing anything. That's just the way it works. Basically, you can't guarantee your audio sync until all of your video editing is done. You can try locking the various audio clips to the video clips at the playhead, using the Advanced menu. That might preserve the sync in most of your movie, depending at what point you removed the edited material. At least you probably could confine the "mess up" to one section of audio. But you still will need to account for the material you edited out, unless you want to leave a blank space there or edit your audio.
    If you do want a blank space at your edit point, just create a space by dragging back the clips that moved over, until its back in sync with the audio. You can make note of how much duration you edited out, so that the created space is of the same duration. Then get out of the timeline and go to the movie clips display. You will see your space displayed as a black clip. Control click on it, and in the resulting drop down menu, select Convert Empty Space to clip, if that's what you want. Of course, that will leave a black space in your movie.

  • Tree control and drop target data

    Hi
    I can't seem to find an answer to my problem anywhere.
    Is it possible to read the data from the node over which an
    item is dragged and accept or reject a drop if for example the node
    data has attribute droppable?
    Attached is the ArrayCollection used to store dummy data.
    I would like to allow dragging elements to Private folder and
    disallow dragging them to Public folder.
    Thanks for any help.

    Yes. Do the logic in the dragOver and dragDrop handlers.
    Tracy

  • Data controls not working when JFrame is not used

    Hi
    I try to use JInternalFrame for my applications and drag and drop stops to work as soon as I change JFrame to JInternalFrame and make code.
    andirus

    Andius,
    JInternalFrame support will be added to JDeveloper 10.1.3. For now, because its only a design time limitation, you could build your frame with JFrame and then turn it into a JInternalFrame.
    Frank

  • AppleScript: How to pass control to dialog when it is opened using do script

    I am running the following AppleScript:
    tell application "Adobe Acrobat Pro" to activate
    tell application "Adobe Acrobat Pro"
              do script "app.execMenuItem(\"GeneralPrefs\");"
      delay 2
              tell application "System Events"
                        tell process "Acrobat"
                                  click button "OK" of window "Preferences"
                        end tell
              end tell
    end tell
    This properly opens the Preferences dialog/window. This part does work. However, then, the script gets stuck and waits until the window closes for continuing. And then, it is no longer possible to click the OK button…
    Am I missing something, and how can I get controls back to the AppleScript when the dialog window has opened?
    Any advice is highly appreciated.
    Max Wyss.

    I am running the following AppleScript:
    tell application "Adobe Acrobat Pro" to activate
    tell application "Adobe Acrobat Pro"
              do script "app.execMenuItem(\"GeneralPrefs\");"
      delay 2
              tell application "System Events"
                        tell process "Acrobat"
                                  click button "OK" of window "Preferences"
                        end tell
              end tell
    end tell
    This properly opens the Preferences dialog/window. This part does work. However, then, the script gets stuck and waits until the window closes for continuing. And then, it is no longer possible to click the OK button…
    Am I missing something, and how can I get controls back to the AppleScript when the dialog window has opened?
    Any advice is highly appreciated.
    Max Wyss.

  • How to export only the form field data in an XFA form when data connection is used

    I have used xml data connection to populate the values in the dropdown. The data to be loaded into the DropDown is very large , So I have used data connection using xml scheme.
    Then I used export data functionality to export all fields in the form to xml.Insead of exporting all the fileds it just export the values of the dropdown which has been binded through Xml Schema.
    I am not having the licenced version of Adobe Life Cycle. Could you help me solving this issue ? I just want both the data binding and the export data functionality.
    Thanks & regards,
    Karthikeya

    If you could use the below command you can get all the field values from the form.
    xfa.data.saveXML("pretty");
    Thanks
    Srini

  • HT204389 Voice control pops up when I try to use Siri so how do i get to siri

    I can't get Siri to pop up

    Also make sure Siri is On in Settings>General>Restrictions.

Maybe you are looking for

  • Issuing an Error in Table Maintenance Event

    Hi, How can I issue an error in the table maintenance event without exiting the screen. When an event is triggered (Before Save), it will perform a check in the data changed or created. It will issue an error when the changes are not correct. But whe

  • Error while caling report through form

    Hi, could someone help with my reports. I am using report 2.5 (old version) I have created a form that calls my report Plese find below command that I execute in my pushbutton DECLARE pl_id ParamList; BEGIN pl_id := Get_Parameter_List('tempdata'); IF

  • Problems with russian characters

    I need to localize my application to russian language and i have problems with their special characters. I use Graphics.drawString method and unicode escape sequences and this works fine on phones like SE, Nokia and Siemens. But some phones are not a

  • Image Justification for Internet Explorer

    I am trying to justify the images altrnately right and then left at http://www.theforrestproject.org/xcertification.html It looks fine in Google Chrome but looks awful in Internet Explorer with large gaps in the text. I would appreciate assistance to

  • Emptying a Binary Tree

    Hello, The problem I'm having is how to empty a binary tree. Here is my code for MyBinaryTree: public class MyBinaryTree implements BinaryTree {    private BinaryTreeNode root;    protected static int numNodes;    private static String tree = "";