Removing Items From Array Collection
Hi. I have an array collection which is made up of items
defined in class PlayListEntry. I want to remove all the items that
have the value of property select set to false. This is what i have
come up with, it works fine, but only removes half the items at a
time. I think this is because when you remove and item with
removeitemat() it shifts the index of the items. How can i get
around this?
Code
private function removeitems():void{
for each (var ple:PlayListEntry in songCollection){
if (ple["select"] != true){
songCollection.removeItemAt(songCollection.getItemIndex(ple));
}
Here's a sample application I wrote that achieves what you're
looking for.
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
layout="absolute">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
[Bindable] private var medalsAC:ArrayCollection = new
ArrayCollection([
{Country:"USA", Gold:35, Silver:39, Bronze:29, select:true},
{Country:"China", Gold:32, Silver:17, Bronze:14,
select:true},
{Country:"Russia", Gold:27, Silver:27, Bronze:38,
select:true},
{Country:"USA2", Gold:35, Silver:39, Bronze:29,
select:false},
{Country:"China2", Gold:32, Silver:17, Bronze:14,
select:false},
{Country:"Russia2", Gold:27, Silver:27, Bronze:38,
select:false},
{Country:"USA3", Gold:35, Silver:39, Bronze:29,
select:true},
{Country:"China3", Gold:32, Silver:17, Bronze:14,
select:true},
{Country:"Russia3", Gold:27, Silver:27, Bronze:38,
select:true}
private function filterItems():void {
for(var i:Number = 0; i < medalsAC.length; i++){
if(medalsAC
.select == false){
// => Remove item
medalsAC.removeItemAt(i);
// => Refresh collection so it see's new change.
medalsAC.refresh();
// => Start at beginning and keep looking
i = 0;
]]>
</mx:Script>
<mx:Button x="10" y="10" label="Remove False Items"
click="filterItems()"/>
<mx:DataGrid left="10" right="10" top="35" bottom="10"
dataProvider="{medalsAC}">
<mx:columns>
<mx:DataGridColumn headerText="Country"
dataField="Country"/>
<mx:DataGridColumn headerText="Gold"
dataField="Gold"/>
<mx:DataGridColumn headerText="Silver"
dataField="Silver"/>
<mx:DataGridColumn headerText="Bronze"
dataField="Bronze"/>
<mx:DataGridColumn headerText="Select"
dataField="select"/>
</mx:columns>
</mx:DataGrid>
</mx:Application>
Similar Messages
-
Hi,
Can i remove a single item in my array or remove all elements???
Tnx all
Beck74This is a quick way to remove an element. It avoids looping which avoids an ArrayIndexOutOfBounds check with every iteration. Also, arraycopy is native which means that it is very efficient and suitable for large arrays.
public class arraytest
public static int[] remove(int _i, int[] _a)
int[] b = new int[_a.length-1];
System.arraycopy( _a, 0, b, 0, _i );
System.arraycopy( _a, _i+1, b, _i, b.length-_i );
return b;
public static void main(String[] args)
int[] a = {1, 2, 3, 4, 5};
// remove element 3
int[] b = remove(3, a);
for( int i=0; i<b.length; i++ ) {
System.out.println( b[i] );
} -
One-to-many relationship - remove item from collection problem
The ArrayCollection keeps folders tree - subtree of folder is kept in children property and is also ArrayCollection. This collection is fed by 'folders' custom assembler defined like this:
Assembler works with adding and deleting top level objects of collection.
Also, when I add new object to children property LCDS issues createItem for new object and then updateItem for children property of parent so everything is fine - new object is persisted and relationship is correct.
When I remove item from children collection ONLY updateItem on assembler is issued, so object is not deleted from repository. Why this managed reletionship works for adding new object to children collection but doesnt work for deleting?Hi;
A simple way may be create a view on referenced tables:
Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
Connected as hr
SQL>
SQL> drop table resources;
Table dropped
SQL> create table resources(id number, name varchar2(12));
Table created
SQL> insert into resources values(1,'Doc....');
1 row inserted
SQL> insert into resources values(2,'Img....');
1 row inserted
SQL> drop table documents;
Table dropped
SQL> create table documents(id number, resource_id number,type varchar2(12));
Table created
SQL> insert into documents values(1,1,'txt');
1 row inserted
SQL> drop table images;
Table dropped
SQL> create table images(id number, resource_id number,path varchar2(24));
Table created
SQL> insert into images values(1,2,'/data01/images/img01.jpg');
1 row inserted
SQL> create or replace view vw_resource_ref as
2 select id, resource_id, type, null as path from documents
3 union
4 select id, resource_id, null as type, path from images;
View created
SQL> select * from resources r inner join vw_resource_ref rv on r.id = rv.resource_id;
ID NAME ID RESOURCE_ID TYPE PATH
1 Doc.... 1 1 txt
2 Img.... 1 2 /data01/images/img01.jpg
SQL> Regards.... -
How to remove item from my array
hi, I have one array with items. now I want to remove all items from array. How it can be possible ?
You're welcome.
I have noticed a few silly mestakes in my posts. You probably caught them, but just for clarity:
1. yourArray.length without brackets ();
2. < instead of <= in the loop conditions;
3. when looping with pop() function, the initial length of the array has to be saved in a variable and this variable should be used in condition, because with each loop the length of array changes:
var arrayLen:int = yourArray.length;
for (var i:int = 0; i < arrayLen ; i++)
yourArray.pop(); -
Excluding Items from Demantra collection
Hi,
Is it possible to exclude the items from being collected to Demantra? Basically, the sales history in Demantra remains, but I don’t want to collect the history going forward.
Thanks
Praveena DasalakunteHi Praveena,
Oracle Demantra does not have the feature of blocking an item as such. But, your requirement can be met using one of the two approaches:-
1. Mark the “Planning Method” of the item to “Not Planned” in Item Master. This would exclude the item from getting collected. With this option, the older history in Demantra would remain (unless you delete it manually) but the new history won’t be collected. Please note that this option would not collect the Item in ODS itself. So, using this option means excluding the item from Other VCP products as well (ASCP, RP, SNO etc).
2.Use the Custom Hooks to manually remove this item in the Demantra Item and Sales Staging table. This would need some development as you may need to have a GUI/table maintaining the list of items to be excluded.
Hope, this helps.
Thanks, Kunal -
How can we remove items from the VF04 list?
We have a long list of items in VF04 that, for various reasons (some process related, some due to errors), are not to be billed. We have looked at applying filters to the list but there is nothing really suitable to hide these individual documents e.g. we could filter out some dates where none of the items on that date are to be billed but other dates have a mix of items we want to bill and others we don't.
I have done a search of this forum but didn't find a previous topic with a quick and simple method to remove items from the list .
Is there a method, other than billing them or sorting each issue individually, to permanently remove individual documents from the VF04 list?
Thanks in advance for any help.
DavidHi,
David,
Download a list of Pending delivers doc form VF04.
Paste the list in T.Code : VL09 (Delivery reversal) and reverse the delivery.
Then go to T.Code: VL06G Select the list of deliveries that has been reversed, select/delete all un- wanted deliveries.
This way you can remove all unwanted pending deliveries forn Billing due list (VF04).
Thanks & Regards,
R.Janakiraman -
How can i update/Remove Items from AR Invoice using SDK?
Hi All,
I have 1 problem with update or remove item from sales order. here is the source code of mine.
If inv.GetByKey(DocumentNumber) = True Then
inv.CardCode = cardcode
Dim ercode As Integer
Dim ind As Integer = 1
For Each drow As DataGridViewRow In gv.Rows
If gv.Rows.Count = ind Then Exit For
ercode = drow.Cells("No").Value
inv.Lines.SetCurrentLine(ercode)
'inv.Lines.ItemCode = drow.Cells("itemcode").Value
'inv.Lines.ItemDescription = drow.Cells("itemname").Value
inv.Lines.Quantity = drow.Cells("qty").Value
inv.Lines.Price = drow.Cells("price").Value
ind = ind + 1
Next
errorcode = inv.Update
If errorcode <> 0 Then
PublicVariable.oCompany.GetLastError(errorcode, errorsms)
Else
errorcode = 0
End If
Else
errorsms = "Not found Invoice Document Number"
End If
After update, it error "[INV1.Quantity][line:1],'Field cannot be updated (ODBC -1029)'"
Does anybody know about this?
Thanks
TONYHi $riniva$ Rachumallu,
This is my mistake that not test manually in application.
Thanks
TONY -
How do I remove items from the cloud without losing them permanently?
My icloud storage is almost full. How do I remove items from the cloud and not lose them?
What items?
Purchased music, movies, TV shows, apps, and books do not use up your iCloud storage.
See the link below for how to reduce the amount of storage you're using:
http://support.apple.com/kb/HT4847 -
How do you remove items from the assets panel that are duplicated?
How do you remove items from the assets panel that are duplicated?
If you add an item to a slideshow, you'll usually see 2 entries for that image in the assets panel - one represents the thumbnail, and the other represents the larger 'hero' image.
It sounds like you may have added the same image to your slideshow twice. You can select one of the hero images or thumbnail images in your slideshow and use the delete key to remove it. Then the extra 2 entries in the assets panel should disappear. -
How do you remove items from the start up disc
How do you remove items from the start up disc?
Freeing Up Space on The Hard Drive
You can remove data from your Home folder except for the /Home/Library/ folder.
Visit The XLab FAQs and read the FAQ on freeing up space on your hard drive.
Also see Freeing space on your Mac OS X startup disk. -
How do I remove items from the dock?
How do I remove items from the dock ?
Single click and then drag it to the desktop. It will dissapear in a puff of smoke. You also may benefit by bookmarking and using:
Find Out How Video tutorials -
Can I remove items from the Services menu?
I think the subject line says it all: can I remove items from the Services menu? I have a number of items in the Services menu that I never use and I would like to make the menu shorter to make it easier to access the items that I do use.
There are a couple of things you could try. There's an application called Service Scrubber that is supposed to do this. But the web page says it's for 10.4, though it says it might work on 10.3
Alternatively, you can edit the Info.plist or Info-macos.plist file in each application bundle to remove its service from the Services menu. This post at Mac OS X Hints has a pretty detailed description of how to do it. I tried this on my iMac running 10.3.9 and it worked just fine.
Don't know about the Service Scrubber app, but if you edit the plist files, you'll need to log out and log back in before the changes take effect.
Also, if you decide to edit the files by hand, I'd suggest just renaming NSServices by adding an "x" to the front or something, rather than deleting the item completely. That makes the changes easier to reverse.
charlie -
How can i remove items from list that have been deleted when i click on them it keeps showing empty
how can i remove items from the list that have been deleted when i click on them it keeps showing folder empty
Actually, Reader SHOULD keep showing documents that no longer exist, I disagree. It's no big deal, and people will quickly realise why they can't open the file. They open more files, the old ones move off.
The REASON why it should not check is that checking whether a file exists can take a long time when things aren't good. For instance if a file server goes down, or a memory card is unplugged. That in turn would mean delays opening the File menu, and I've seen some software that can sit there for several minutes. That would really give people something of which to complain... -
How can I remove items from the open a recent file menue.
How can I remove items from the "Open a Recent File" menue. Many other applications allow the clearing of that file . Is this possible in Adobe Reader 10.1.2 ? If so how?
See this previous topic: http://forums.adobe.com/message/3759596
It is for Acrobat, but the registry entries are similar for Reader. -
How can I add and remove items from the bookmarks toolbar?
I want to remove items from the bookmarks toolbar and add ones that I use on a regular basis. How can I do this?
See:
*https://developer.mozilla.org/en/Chrome
*http://en.wikipedia.org/wiki/User_interface_chrome#User_interface_and_interaction_design
Maybe you are looking for
-
I am getting a warning sign related to Console (9y7:36) and a box with >- related to Terminal in my dock. Also when I click on terminal there is a heading "bash 80 X 24" after my name in favourites. Can someone give me any idea what this could be ab
-
after upgrading to IOS 5.1 I no longer can see Verizon at the top of my Iphone and under settings>general>Network>says Not Available Why is this? Did the upgrade cause this? steve
-
I know there are several posts here that express the same issue, but I cannot find any definitive resolution, so I will ask the question again. iPhone 3Gs, iOS 4.2.1, in the iPod application, the list of songs and artists does not line up correctly w
-
Develop Settings - Process Version
The process version in the develop settings is sometimes nil, sometimes '5.0'(2003), and sometimes '5.7'(2010). - Begging the questions: (I haven't checked every one but so far if its read as nil by plugin, they're shown as 2003 in Lightroom UI) 1. W
-
Root CA certs repository of Linux FlashPlayer plugin
Hello. My application uses RTMPS. This is not browser's SSL but FlashPlayer's native SSL. Windows client works good. But Linux client cannot connect the server. This is server log. SSL state (accept): before/accept initialization SSL state (accept):