flex - Advanced Data Grid: Error: Bookmark no longer valid -


i working on indent , outdent advanced datagrid. have set of functions work when operating on underlying data fine, throw "error: bookmark no longer valid" when operating on selected items of datagrid.

when run code runs fine:

indentleaf(l5) outdentleaf(l4) 

but code fails:

adg.selecteditem = l5 indentleaf(adg.selecteditem leaf) adg.selecteditem = l4 outdentleaf(adg.selecteditem leaf) 

the code not fail in instances, configurations of data grid data tree.

the code needs run in debugger version of flash player if want see error thrown. have cut , pasted error text area reference below.

the code in toy app seems recover ok when exception thrown, in larger app leads hard crashes.

example code can found here view source turned on: http://www.crcarlson.com/adg/adgarraycollectionupdate.swf

to create error, reset tree , click "indent/outdent2"

i appreciate suggestions on how around this.

the full stack trace looks this:

error: bookmark no longer valid. @ listcollectionviewcursor/seek()[e:\dev\4.x\frameworks\projects\framework\src\mx\collections\listcollectionview.as:2417] @ mx.collections::hierarchicalcollectionviewcursor/get current()[e:\dev\4.x\frameworks\projects\datavisualization\src\mx\collections\hierarchicalcollectionviewcursor.as:220] @ mx.collections::hierarchicalcollectionviewcursor/collectionchangehandler()[e:\dev\4.x\frameworks\projects\datavisualization\src\mx\collections\hierarchicalcollectionviewcursor.as:1143] @ flash.events::eventdispatcher/dispatcheventfunction() @ flash.events::eventdispatcher/dispatchevent() @ mx.collections::hierarchicalcollectionview/nestedcollectionchangehandler()[e:\dev\4.x\frameworks\projects\datavisualization\src\mx\collections\hierarchicalcollectionview.as:1595] @ flash.events::eventdispatcher/dispatcheventfunction() @ flash.events::eventdispatcher/dispatchevent() @ mx.collections::listcollectionview/dispatchevent()[e:\dev\4.x\frameworks\projects\framework\src\mx\collections\listcollectionview.as:1024] @ mx.collections::listcollectionview/handlepropertychangeevents()[e:\dev\4.x\frameworks\projects\framework\src\mx\collections\listcollectionview.as:1433] @ mx.collections::listcollectionview/listchangehandler()[e:\dev\4.x\frameworks\projects\framework\src\mx\collections\listcollectionview.as:1300] @ flash.events::eventdispatcher/dispatcheventfunction() @ flash.events::eventdispatcher/dispatchevent() @ mx.collections::arraylist/internaldispatchevent()[e:\dev\4.x\frameworks\projects\framework\src\mx\collections\arraylist.as:673] @ mx.collections::arraylist/itemupdatehandler()[e:\dev\4.x\frameworks\projects\framework\src\mx\collections\arraylist.as:704] @ flash.events::eventdispatcher/dispatcheventfunction() @ flash.events::eventdispatcher/dispatchevent() @ leaf/dispatchchildrenchanged()[c:\adobeflextraining\_workspace\adgarraycollectionupdate\src\leaf.as:119] @ leaf/addchildat()[c:\adobeflextraining\_workspace\adgarraycollectionupdate\src\leaf.as:63] @ leaf/move()[c:\adobeflextraining\_workspace\adgarraycollectionupdate\src\leaf.as:96] @ adgarraycollectionupdate/outdentleaf()[c:\adobeflextraining\_workspace\adgarraycollectionupdate\src\adgarraycollectionupdate.mxml:86] @ adgarraycollectionupdate/io2_clickhandler()[c:\adobeflextraining\_workspace\adgarraycollectionupdate\src\adgarraycollectionupdate.mxml:113] @ adgarraycollectionupdate/__io2_click()[c:\adobeflextraining\_workspace\adgarraycollectionupdate\src\adgarraycollectionupdate.mxml:183] 

i found workaround bug (i using sdk 3.5 guess 4.1 fix same). problem lies within "current()" getter of hierarchicalcollectionviewcursor class.

it doesn't catch cursorerror that's caused invalid bookmark.

step 1 create better cursor class:

public class hierarchicalcollectionviewcursor2 extends hierarchicalcollectionviewcursor {     public function hierarchicalcollectionviewcursor2(collection:hierarchicalcollectionview, model:icollectionview, hierarchicaldata:ihierarchicaldata)     {         super(collection, model, hierarchicaldata);     }       override public function current() : object     {         // original hierarchicalcollectionviewcursor class fails catch "bookmark no         // longer valid" error, thrown collectionviewerror instance in listcollectionview,         // transformed cursorerror within same class         try {             var result:object = super.current;         }         catch (e:cursorerror) {             result = null;         }          // done         return result;     } } 

step 2 create hierarchicalcollectionview class, returns new cursor:

use namespace mx_internal;  public class hierarchicalcollectionview2 extends hierarchicalcollectionview {     public function hierarchicalcollectionview2(hierarchicaldata:ihierarchicaldata=null, argopennodes:object=null)     {         super(hierarchicaldata, argopennodes);     }       override public function createcursor() : iviewcursor     {         return new hierarchicalcollectionviewcursor2(this, treedata, this.source);     } } 

step 3 use new hierarchicalcollectionview2 class data-provider.

var itemsac:arraycollection = new arraycollection(); // add items etc this.adgdataprovider = new hierarchicalcollectionview2(new hierarchicaldata(itemsac)); 

now think drama wouldn't complete without annoying flex-sdk bug. in case its:

https://bugs.adobe.com/jira/browse/flexdmv-1846

so, step 4 subclass advanceddatagrid component described in bug issue.

that's -- works me!


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -