Advertisement

08.05.2008 at 12:35PM PDT, ID: 23623546
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.3

How to find and replace text within an Array Collection in Flex 3

Asked by thawts in Adobe Flex

Tags: , ,

K here is my code, i am loading a xml file into the flex file and populating a datagrid.  I actually use the browser manager to get variables across the url that i use in a URL request but i have taken the URL request out and just put data.xml for the loaded information in this code.  My question is the xml comes back with 1 and a 2 and a 3 for AdvancedDataGridColumn of Rank dataField="Rank_Index".  Is there anyway i can find and replace with that column or find and replace in general 2= bronze, 3 - silver etc with in my myAC Array Collection.  Ideally the change would be done on the datasources end but since i cant do that i am wondering if I can do it on my end.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"  historyManagementEnabled="false" creationComplete="init(event),myHS.send()" >
    <mx:Script>
    <![CDATA[
        import mx.managers.BrowserManager;
        import mx.managers.IBrowserManager;
        import mx.utils.URLUtil;

        private var bm:IBrowserManager;
        [Bindable]
        private var fName:String;
        [Bindable]
        private var lName:String;            

        private function init(e:Event):void {
            bm = BrowserManager.getInstance();                
            bm.init("", "Welcome!");

            /* The following code will parse a URL that passes firstName and lastName as
               query string parameters after the "#" sign; for example:
               http://www.mydomain.com/MyApp.html#firstName=Nick&lastName=Danger */
            var o:Object = URLUtil.stringToObject(bm.fragment, "&");                
            fName = o.Max4UUserID;
            lName = o.DistId;
                         
        }
    ]]>
    </mx:Script>
<mx:HTTPService id="myHS" url="data.xml" result="gotResult(event)"/>
<mx:Script>
      <![CDATA[
            import mx.collections.SortField;
            import mx.collections.Sort;
            import mx.collections.IViewCursor;
            import mx.events.FlexEvent;
            import mx.collections.ArrayCollection;
            import mx.rpc.events.ResultEvent;
           
            [Bindable] private var cursor:IViewCursor;
            [Bindable] private var myAC:ArrayCollection;
                     
            private function initApp():void
                  {
                  this.myHS.send();
                  }
            private function gotResult(e:Object):void
            {
                this.myAC = myHS.lastResult.results.row as ArrayCollection
                if( this.myAC)
                {
                        var sort:Sort = new Sort();
                        sort.fields = [ new SortField("ROMAN_NAME_1",true) ];
                        this.myAC.sort = sort;
                        this.myAC.refresh();
                        this.cursor = this.myAC.createCursor();
                       
                }
            }
                                   
            private function searchID():void
                        {
                        if(search_ti.text != "")
                        {
                        if(this.cursor.findFirst({ROMAN_NAME_1:search_ti.text}))
                        {
                      var idx:int = this.myAC.getItemIndex(this.cursor.current);
                      this.myADG.scrollToIndex(idx);
                      this.myADG.selectedItem = this.cursor.current;
                        }
                        }
                        }
        public function highlightID(data:Object, column:AdvancedDataGridColumn):Object
        {
            if (data.DIST_ID > 3000)
                return { color : "blue" };
            else
                return null;
        }        
       
                        private function refilter():void
                        {
                                if( filter.text.length == 0)
                                        this.myAC.filterFunction = null;
                                else
                                        this.myAC.filterFunction = filterAC;                            
                                this.myAC.refresh();
                        }
                        private function filterAC( e:Object):Boolean
                        {
                                if( String(e.ROMAN_NAME_1).substr(0, filter.text.length) == filter.text)
                                        return true;    
                                return false;
                        }        
       
       
      ]]>
</mx:Script>
<mx:Form>
        <mx:FormItem label="First name:">
            <mx:Label id="ti1" text="{fName}"/>
        </mx:FormItem>
        <mx:FormItem label="Last name:">
            <mx:Label id="ti2" text="{lName}"/>
        </mx:FormItem>
    </mx:Form>
<mx:Form x="0" y="165" alpha="0.0">
            <mx:FormItem alpha="0.0">
                  <mx:TextInput id="search_ti"/>
            </mx:FormItem>
                  <mx:FormItem>
                        <mx:Button click="searchID()" alpha="0.0"/>
                  </mx:FormItem>
      </mx:Form>
<mx:Form verticalCenter="-229" horizontalCenter="-12">
            <mx:FormItem label="Search">
                  <mx:TextInput id="filter" change="refilter()"/>
            </mx:FormItem>
      </mx:Form>
     
<mx:Panel width="612" height="456" layout="absolute" horizontalCenter="0" verticalCenter="18" resizeEffect="Resize" title="Top 25 Report">
 
 
<mx:AdvancedDataGrid id="myADG" dataProvider="{myAC}" width="542" variableRowHeight="true" wordWrap="true" height="422" horizontalCenter="0" verticalCenter="2">
  <mx:columns>
    <mx:AdvancedDataGridColumn headerText="Name" dataField="ROMAN_NAME_1" />
    <mx:AdvancedDataGridColumn headerText="Enrollment Date" dataField="ENTRY_DATE"/>
    <mx:AdvancedDataGridColumn headerText="Type" dataField="SHORT_DESC" />
    <mx:AdvancedDataGridColumn headerText="Rank" dataField="RANK_INDEX" />
    <mx:AdvancedDataGridColumn headerText="Date Achieved" dataField="EFFECTIVE_DATE" />
  </mx:columns>
</mx:AdvancedDataGrid>
     
</mx:Panel>
</mx:Application>
Start Free Trial
[+][-]08.14.2008 at 08:55AM PDT, ID: 22231399

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Adobe Flex
Tags: Flex 3, Flex 3, Flex 3
Sign Up Now!
Solution Provided By: remmuh
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20081112-EE-VQP-42 / EE_QW_2_20070628