Subset of an arrayCollection

How do I select a subset of an array
Collection to appear in a datagrid? For example, in the code below, how do I select only the records where pop > 2000?
<?xml version="1.0"?>
<!-- dpcontrols\SimpleDP.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"  creationComplete="creationCompleteHandler()">
    <mx:Script>
        <![CDATA[
import mx.collections.ArrayCollection;
[Bindable] private var _populations:ArrayCollection;
            public function creationCompleteHandler():void {
                _populations=new ArrayCollection;
                _populations.addItem({country: "Canada", continent:"NA", pop:"50"});
                _populations.addItem({country: "Ven", continent:"SA", pop:"1000"});
                _populations.addItem({country: "USA", continent:"NA", pop:"5000"});
                _populations.addItem({country: "Brazil", continent:"SA", pop:"4000"});
         ]]>
    </mx:Script>
    <mx:DataGrid  id="datagrid"   dataProvider="{_populations}" width="100%" height="100%" />
</mx:Application>

hi,
You use a filter function on your array collection, this is reasonably simple I have a basic example which I did for another poster a few weeks back
http://flashhub.net/filter/ - source is included
So your filter would look something like this, you could hard code the value in but it is always better to use variables so that any part of your program can alter the filter requirements.
                        private var minPopulation: int = 500;  <=== global variable
            protected function arrColl_filterFunc(item:Object):Boolean
                    if (item.pop > minPopulation)               
                        return true    
                    else
                        return false;

Similar Messages

  • Vertical slider as tag filter

    I am creating a tag filter like the one on http://nines.org/tags
    They have a vertical slider that filters (increases and decreases) the tags.
    I have an ArrayCollection of tags, and I want the vertical slider value to dictate how many tags are shown in the textArea, just like the one in the example on the site. How do I do this?
    Thanks.

    Hmm.. okay, the Vertical Slider will have a "value" property to access the current value. So something like..
    vSliderId.value
    .. should get you the value.
    Now depending on how your ArrayCollection is writing tags into a TextArea, I believe only a limited portion / subset of the ArrayCollection can be used to generate tags inside your TextArea.

  • From ArrayCollection to Array in DataBinding

    Hi,
    I am trying to use somebody else's visual component (have src code of that mxml),
    which uses Array items as a DataSource.
    In my program I use ArrayCollection to hold my data (from the data feed - changes in real time).
    I need to pass some data from my ArrayCollection into that component inside the binding,
    something like:
    <view:Component1  items="{dataArrayCollection}"?? />
    currently have in Component1.mxml:
    public function set items(a:Array):void {...}
    Since that component is pretty complicated, I would not want to break its logic,
    so I am thinking of adding some data adapter, public method to Component1 like:
    public function set dataProvider(ac:ArrayCollection):void {
    Array tempArr = new Array();
    // copy some data from ac -> tempArr
    items(tempArr);
    and do: <view:Component1  dataProvider="{dataArrayCollection}" />
    Is there a more efficient way of doing that (I guess, "set dataProvider" will be called a lot, on each update)?
    I don't think I can just straight convert ArrayCollection -> Array, need just a small subset of data.
    Please advise.
    TIA,
    Oleg.

    Alex,
    A friend suggested me another solution, which I tried and it seems to work and be more straightforward:
    main.xml:
    [Bindable]
      private var ac : ArrayCollection;
    <component dataProvider="{ac}" />
    Component.xml:
    [Bindable]       
    public var dataProvider:ArrayCollection;
    private function onCreationComplete():void {
       dataProvider.addEventListener(CollectionEvent.COLLECTION_CHANGE, onDataProviderUpdate);
    public function onDataProviderUpdate(e:*=null):void {
                    if (dataProvider == null) {                  
                        return;
                    var aca:Array = dataProvider.source;                                
                    var dev1:Object = aca[0];    // process only 1 element of that AC                   
                    var dev:Device = new Device();
                    dev.cpu = dev1["cpu"];
                    // pass to items array
                    if (_items == null) {    // if new                    // _items - component's data array              
                        _items = new Array();
                        _items.push(dev);                                                
                    } else {                   
                        _items.push(dev);    
                        updateData();                   
                    updateView();                          
    Do you like that solution ?
    The only problem I see is that when the feed runs, the size of the browser memory grows fast,
    so by element 60 it slows down, by 95 memory consumption grows to 1.4GB and browser crashes.
    I do not think it is related to that data binding, but not positive.
    Can it be array.push() ?
    Any way to force garbage collection in Flex ?
    Please advise,
    Oleg.

  • Determine subset of dataprovider being shown in a DataGrid

    I need to be able to determine the subset of rows that a DataGrid is displaying. For example, say I have a DataGrid that is showing 20 rows (i.e. rowCount=20). My ArrayCollection 'data' has 500 items in it. I need to know that items data[125] through data[144] are being shown. So at a minimum I need to know the index of the first item (or last) being displayed and I can do the math using the rowCount. How can I do that? I've looked through the DataGrid properties, but am not seeing anything I can use.
    Thanks

    Found I can use the verticalScrollPosition to get the index of the item in the first row.

  • Whats the difference between arrayCollection = null and arrayCollection.removeAll()?

    Whats the difference between arrayCollection = null and
    arrayCollection.removeAll()?

    In arrayCollection = null; statement you're setting this
    reference to null and potentially making it available for garbage
    collection. I say 'this reference' and potentially because, as you
    may know, there might be other references to this array collection
    object that won't be affected by this statement and hence it won't
    be GC'ed.
    arrayCollection.removeAll() says that I want to empty this
    array collection for all the reference that we pointing to it. That
    is, remove all the objects from the collection -- and of course
    make them 'potentially' available for the GC -- the size of the
    array collection would be reduced down to zero and all the
    references would be pointing to a valid but empty collection.
    Hope this helps.
    ATTA

  • How to get a subset of text from a varchar2 field

    Hello.  I am trying to select a subset of text from a varchar2 field.  This is login information from dba_audit_trail view.  Here's an example of the field (comment_text from dba_audit_trail):
    Authenticated by: DIRECTORY PASSWORD;EXTERNAL NAME: cn=orcladmin,cn=Users,dc=idacorp,dc=local; Client address: (ADDRESS=(PROTOCOL=tcp)(HOST=555.555.555.555)(PORT=99999))
    I am trying to just select the "orcladmin" text - i.e. everything after the first "=" up to the first ","
    I can get everything after the first "=" with this:
    select substr(comment_text, instr(comment_text, '=') + 1) from dba_audit_trail
    ... but I don't know how to stop at the first ","
    Any help would be greatly appreciated.
    Thanks!
    Message was edited by: DRC

    Hi,
    Here's one way to do it:
    WITH got_pos    AS
        SELECT  comment_text    -- and whatever other columns you need
        ,       INSTR (cooment_text, '=')   AS equal_pos
        ,       INSTR (cooment_text, ',')   AS comma_pos
        FROM    dba_auit_trail
        WHERE   ...             -- any filtering goes here
    SELECT  SUBSTR ( comment_text
                   , equal_pos + 1
                   , comma_pos - (equal_pos + 1)
                   )   AS first_cn
    FROM    got_pos
    You could do it without a sub-query; you'd just have to do the exact same INSTR 2 times, where I used equal_pos 2 times.
    You could also get the results you want using regular expressions, such as:
    SELECT  REGEXP_SUBSTR ( comment_text
                          , '=([^,]*),'
                          , 1
                          , 1
                          , NULL
                          , 1
                          )      AS first_cn
    FROM    dba_audit_trail
    Although this uses less code, it's slower than using INSTR and SUBSTR .

  • Getting values from a datagrid to an ArrayCollection

    Hi, I have a drag and dropable datagrid. I fill it with rows of data from another datagrid. Finally, my application demands savings the data from the datagrid into an array collection along with the index of each row. How do i get values from a datagrid into an arrayCollection variable? Please help me..!

    Whatever is dropped into the DataGrid automatically goes into its dataProvider property, typically an ArrayCollection. Just access the data grid's dataProvider property to see the values.

  • Oracle Reports 11.1.2.0.0, [PDF:subset] failed.

    Hi Expert,
    Refer to document “How to Use Font Subsetting in Reports for PDF Output [ID 207711.1]” , setup font subset in Oracle Forms 11.1.2.0.0 failed.
    Copy simsun.ttf file to <ORACLE_HOME>/reports/fonts.
    Add <ORACLE_HOME>/reports/fonts directory to the REPORTS_PATH in reports.sh.
    Go to Oracle Enterprise Manager --> Reports Server Home Page
    and going through menu options : "Reports --> Administration --> Forms/Reports Common Configuration" page
    Add fonts to section PDF Subsetting area like:
    Font Mapped Font
    "宋体" "simsun.ttf"
    Save it.
    Check the report, it was not able to display simsun.
    And found that the setting "宋体" which setted in EM corrupt in uifont.ali file.
    If modify uifont.ali file like below,
    [PDF:Subset]
    * = "simsun.ttf"
    Then the report can display simsun as normal.
    I have tested that the issue not occur on windows.
    Will any expert can give some advise?
    Thank you in advance!

    hi,
    you have to touch following files.
    $ORACLE_HOME/guicommon/tk/admin/AFM
    $ORACLE_HOME/guicommon/tk/admin/AFM/Symbol.afm
    $ORACLE_HOME/guicommon/tk/admin/TTF
    $ORACLE_HOME/guicommon/tk/admin/uiprint.txt
    $ORACLE_HOME/guicommon/tk/admin/uifont.ali
    $ORACLE_HOME/guicommon/tk/admin/PPD/datap462.ppd
    $ORACLE_HOME/guicommon/tk/admin/PPD/screenprinter.ppd
    $ORACLE_HOME/bin/reports.sh
    convert your true type font to afm and copy ttf/afm files to respective directory
    regards

  • How can I open a tdms file and replace a subset of data then save that change without re-writing the entire file again?

    Hi all,
    Is it possible to open a tdms file and make a small change an an array subset then save the file without having to save the whole dataset as a different file with a new name? That is to say, is there something similar to "Save" in MS Word rather than "Save As"... I only want to change a 1D array of four data points in a file of 7M data points.
    I am not sure if this make sense? Any help is apreciated.
    Thanks,
    Jack

    You can use either one, but for your application, I would use the synchronous.  It requires far less setup.  When you open the file, set both enable asynchronous and disable buffering to FALSE to enable you to use synchronous with arbitrary data sizes.
    Attached code is LabVIEW 2011.
    This account is no longer active. Contact ShadesOfGray for current posts and information.
    Attachments:
    UpdateTDMS.zip ‏20 KB

  • How to Broadcast subset of a data in a report to the respective users

    Hi
    I have to broadcast the subset of a data in a report to different users. I believe this can be done using busting email broadcasting option. But im not sure about the settings.
    My report looks like below:
    Accounting Clerk             Customer              Invoice Amount           Discount Amount
    Clerk1                               Customer1           100                              50
    Clerk1                               Customer 2           200                              70
    Clerk2                               Customer3            150                              55
    Clerk2                               Customer4            80                                10
    I need to broadcast the above report to my respective accounting clerks. ie I need to broadcast only the first two records to clerk1 as an email and only the last two records to Clerk 2.  The accouting clerk info object has email address as an attribute.
    Please let me know how to achieve the above requirement. Your help would be highly appreciated.
    Regards
    Sadeesh

    Thanks for the reply Alex.
    Is it mandatory to maintain the email address in SU01 or can the email adddress be maintained as an attribute of say accounting clerk in my example?
    For example say i have 20 accounting clerk, do i need to create 20 variants one for each accounting clerk in broadcasting? Please clarify.
    If yes for the above query, are there any way to reduce the no of variants.
    Your help would be highly appreciated.
    Regards
    Sadeesh

  • Font subsetting issue with srw.run_report

    I have PDF subsetting as
    "Courier" = "MSGOTHIC.TTC"
    I have a report emp.rdf. This emp report just displays the data from emp table.
    I have a report dept.rdf. This dept report just displays the data from dept table.
    In the after report trigger of the dept, I added
    srw.run_report(report=emp destype=file desname=emp.pdf desformat=pdf);
    I am running the dept report from command line as
    rwclient server=<servername> userid=<user/pwd@db> report=dept destype=file desname=dept.pdf desformat=pdf
    The report hangs. I tried moving the after report trigger to before report trigger and it fails too.
    Any ideas?

    Hi,
    Can you try running this report from the Reports Builder, ie, use File > Generate to file > pdf, and see if both the master and child files are generated.
    If yes, can you post both server and engine trace file contents (last few lines) of the instance when you run it from the server, and not from Builder.
    Navneet.

  • Problem updating a SOAP Web Service with ArrayCollection

    Hello,
    I am having issues POST'ing an ArrayCollection to a C# Web
    Method. Here's how I have my application set up:
    I have a DataGrid in my application and set the dataProvider
    to be the result object of a Web Service operation. I set the
    DataGrid's editable property to "true" and would like to be able to
    edit the data and send off the DataGrid's dataProvider as the
    parameter for the Web Method. If I edit the first row of the
    DataGrid and trigger the operation, it gets saved just fine. If I
    try to edit any other row this way, it keeps sending the same
    packet (as verified by a packet sniffer) not allowing me to update
    any other row. It seems the Web Service is sending the first 255
    characters of the serialized ArrayCollection.
    My questions are: why is this happening?
    and
    How can I fix this?
    Here is the request of my Web Service operation:
    <mx:request xmlns="">
    <GlossaryTerms>
    {GlossaryArrayCollection}
    </GlossaryTerms>
    </mx:request>
    This is the definition of GlossaryArrayCollection:
    [Bindable]
    public var GlossaryArrayCollection:ArrayCollection = new
    ArrayCollection();
    Here is the SOAP packet that the C# Web Method is expecting:
    <?xml version="1.0" encoding="utf-8"?>
    <soap12:Envelope xmlns:xsi="
    http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="
    http://www.w3.org/2001/XMLSchema"
    xmlns:soap12="
    http://www.w3.org/2003/05/soap-envelope">
    <soap12:Body>
    <GlossaryUpdate xmlns="">
    <GlossaryTerms>
    <Glossary cID="int" cDeleted="boolean" cTerm="string"
    cDefinition="string" cURL="string" cPublic="boolean"
    cRowVersion="string"/>
    <Glossary cID="int" cDeleted="boolean" cTerm="string"
    cDefinition="string" cURL="string" cPublic="boolean"
    cRowVersion="string" />
    </GlossaryTerms>
    </GlossaryUpdate>
    </soap12:Body>
    </soap12:Envelope>
    Thanks to anyone for their help.
    Brian Cary

    Where exactly you are seeing this error? possible for you share the screenshot?
    Execution failed: These policy alternatives can not be satisfied:
    {http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}SupportingTokens

  • How can I view only a subset of my contacts in iOS?

    I have a large number of contacts.  I sync my contacts with iPad, iPhone, and Mac Contacts.  How can I group my contacts, then choose to view only one group?
    I see how to create groups in OSX, although it is a little tedious to begin with to create a field for grouping for each and every contact.  But I cannot see how to use these groups in iOS7, or maintain the grouping field, or view only a subset of all accounts.  My goal is to create a group of personal contacts, like favorites, then see only those contacts by default but have access to all contacts if I need to.

    How can I select only a portion of my screen to be recorded with QuickTime?  I've seen this as an option online but can't figure out how to make the program able to highlight a certain area of my screen to be recorded.
    If you are still using Snlow Leopard, then you can't. This functionality was added to QT 10.1 which runs under Lion.

  • How to move only subset of data from one database to another?

    Both source & destination are Oracle11g databases.
    The requirement details are as below,
    1) The database contains static as well as transactional data for telecom domain.
    2) We have to move region-wise data from one database to another.
    3) There are around 10 regions.
    4) The region wise data extraction from source db is based on around 40 to 50 tables. Rest of the tables contains
    static data & it will not change.
    5) The volume is around 1 million subscribers per region.
    6) The migration is required because
    a) The client is upgrading its base product which uses this database
    b) There is a change in structure of static tables
    c) Hardware upgrade
    d) The client want to start with single region on new database & rest of the regions will be operated from old
    database.
    7) Keep execution time to very minimum.
    I am thinking to have solution as below,
    1) Create destination database with upgraded db structure (as mentioned in 6b)
    2) Create database links to access source db in destination db.
    3) Write SQL queries to fetch data from all the respective tables for a specific region
    4) Write separate PL/SQL blocks for each table to fetch data from source db & insert into respective table in
    destination db
    a) Use FOR ALL & bulk collect to improve the performance
    b) Divide table data into multiple chunks & execute parallel batches (around 10) to insert the data
    5) Validate pre & post counts to verify the success of migration
    Is there any other better way?
    Regards,
    Sandeep

    How to move only subset of data from a partiular table by using transportable tablespace?
    E.g. SUB table using SMP_SUB tablespace contains subscriber data in source database.
    The indexes defined on SUB table are under SMP_IDX_SUB tablespace
    The subscribers data can be categorized by different regions, say region_id column. Then how to move data & indexes of SUB table from source db to destination db?
    any specific example would be helpful.

  • I have 2 Macs - an iMac that holds my entire iPhoto library and a Mac Book Pro that I use to hold a subset of the main library - how can I transfer photos and their metadata from the main library of the iMac to my Mac Book?

    I have 2 Macs - an iMac which holds my main iPhoto library and a Mac Book Pro which holds a subset of the library. How can I transfer photos and their metadata from the main library to the smaller 1 on the Mac Book Pro?

    Link the two Macs together and use iPhoto Library Manager
    Regards
    TD

Maybe you are looking for

  • My phone wont let me send a text

    okay so i have been texting someone this weekend and i wanted to tell them goodnight right, so i sent the message and it said message not sent review and try again. i tried to sent it again and again and i tried about 20 times to resend it. where i h

  • Fm to get current + next 3 fiscal months name

    hi all, In my alv report , i need to populate the stock of current fiscal month plus stock for succeeding 3 months.Using fm 'GET_CURRENT_YEAR' i am getting current month details with input sydatum and company code. But how to get next 3 fiscal months

  • Trail balance by ob58(financial statement version)

    Hi Experts, At present i have coded one report which produces debits and credits ie Trail Balance by property..... but the requirement now they are asking is that i want to display the output of the Trail balance by Financial Statement item the where

  • Dont receive SMS from ONE person only. I am AT&T, they are Verizon

    Since my friend swithed to a BB Pearl, I am unable to receive SMS from her. On her old phone I received them. Since getting the BB Pearl I do not receive them. They show up as sent on her phone but I get nothing. I am on a blackberry curve with AT&T.

  • Difference between mapping and Source?

    Gurus Can you please expalin me the difference between adding a table ( Ex tabB ) to source Of another table (ex TabA ) , to Mapping TabA to TabB ? Thanks...