Saturday, October 01, 2005

Datagrid refresh contents

First a complaint.
What is up with all these Flash components? They appear unstable and buggy, screw up my depths (MovieClip.getNextHighestDepth()) .. i had hoped these issues would have been addressed with flash 8, but no luck.
Today i ran into this one..,
I have a dataGrid on my Stage with two columns. 1st : name & 2nd : url
Then somewhere in my app i want to dynamically change the value of one of these 2.
This line does that :

myDataGrid.getItemAt(myDataGrid.selectedIndex).url=link;

But does it? When i tried this, at first i didn't see it! But then when i rolled over the item with my mousepointer... there it was... damn.
So i thought, ok... i need a refresh thing on it.
I tried :

myDataGrid.redraw() : doesn't work
myDataGrid.invalidate() : doesn't work

unbelievable no?
now here's your solution :

myDataGrid.dataProvider=myDataGrid.dataProvider;

et voila! there it is...
pfffffffffffff what a day....

13 Comments:

Blogger blankfist said...

Flash is the bane of my existence, yet it's also the provider of my existence, so to speak. Components are a tragedy. I typically find it better to create my own, unless I really don't need the component to be changed, reskinned or to be all that dynamic, for that matter.

Just my two cents.

11:11 PM  
Blogger asji said...

We are on the same page.
I did a flash version for :
www.adje.nl (classifieds)
Components were a consideration for like 10 seconds. I also made my own stuff. But none-compiled clips tend to scroll (interact)slower... and all in all it get's to be a big job to make these components cover all the angles.
Thanks for the comment btw! You're the first on my blog! :)

chao

11:21 PM  
Anonymous sajjaass said...

hihi, I'm looking for some help to build an interactive datagrid using flash. Will you be interested?

1:13 PM  
Blogger asji said...

I'm always interested to help...
Just let me know what you're working on and/or what you need.

2:03 PM  
Anonymous Nitin Malhotra said...

Thank you, thank you, thank you!

I just ran into this issue a couple of hours ago and I've been going nuts trying to figure it out.

And thanks to google for indexing your page so well so I could find my answer!

You both saved me countless of hours of frustration!

5:43 AM  
Anonymous Anonymous said...

Kudos from me as well. I've had this problem for a long time and couldn't figure out how to get it to refresh. Thanks. Ron

10:39 PM  
Anonymous Al McNicoll said...

With you all the way on components - they have the potential to save so much time... but they don't!

Thanks for your solution: after trying so many different combinations of invalidate and redraw, including trying to dig down into the internal structure of the component, I was all ready to give up - fortunately Google could help!

5:58 PM  
Anonymous steve said...

Old blog entry but still solved my refresh problem. Thanks! :)

5:31 PM  
Anonymous Rossman said...

You can also do something like:

---
this.createClassObject(mx.controls.DataGrid, "my_dg", 10, {columnNames:["name", "score"]});
my_dg.setSize(140, 100);
my_dg.move(10, 40);

var myDP_array:Array = new Array();
myDP_array.push({name:"Clark", score:3135});
myDP_array.push({name:"Bruce", score:403});
myDP_array.push({name:"Peter", score:25});
my_dg.dataProvider = myDP_array;

_root.btn_change.onRelease = function() {
myDP_array[1].score = 9999;
my_dg.selectedIndex = 1;
my_dg.selectedIndex = null;
}

8:03 PM  
Anonymous Simon said...

Cheers mate

Saved me a few hours of headaches with that!!

Tried redraw etc to no avail first too!

5:59 PM  
Blogger isdito said...

Tanks for all save me hours...!!!

2:33 PM  
Anonymous Anonymous said...

I know this forum has been up for some time... however, I want to thank you. I've been trying to refresh my dataGrid for some time now, nothing has worked except for this.

Woo-Hoo!

4:04 AM  
Anonymous Anonymous said...

Thank you I have been messing with this all day

8:36 PM  

Post a Comment

<< Home