0
votes

Im working with a flex application that pulls data from a java class file using message handler event. The received message string is added to ArrayCollection. The string consists of codeID and other values related to codeID. Had displayed the detail in a datagrid. The codeID is randomly generated and is pushed to flex for every second. Now, the problem is, I needa update the datagrid cell values, for instance, if i have pushed codeID's of (0001,0007,0005,0003) to the front end, that displays the corresponding values of each codeID in the datagrid, second instance of (0001) should update records in the existing row of (0001). I tried to check the existence of codeID in ArrayCollection using search algorithm, but dont know how to proceed further.

Any help is most apprecited. Thanks in advance.

1
You probably want to have some kind of persisting layout that keeps an associative array of the object within the array collection to the codeId(key). This way it's easier to reference to and update. - J_A_X

1 Answers

1
votes

Sort the ArrayCollection in ascending order and refresh the same.

var dataSort:Sort = new Sort();

dataSort.fields =  [new SortField("code", true, false), new SortField("time", true, false)];


Collection.sort = dataSort;

Collection.refresh();

Check for the existence of codeID using Binary search and retrieve the index. Using,

collection.removeItemAt(index); 

will remove the previous record of codeID(0001) and inserts the current record of the same.