PDA

View Full Version : DataGrid Authoring


gaf3
02-08-2005, 05:22 AM
Heyas,

I have a really bizarre problem. I've been extending the built in components so as I can set things like font, colors, all in the component properties panel. I just want to separate form from function, rather than have to compile every time I want to see what something looks like.

So I'm at the DataGrid component (after sucessfully overriding things like List, Button, ComboxBox, etc.) and I thought it would be a good idea to display a sample of what would be display. So I have a boolean flag (_sample) with the
getter/setter functions, and when sample is true, it creates a couple of columns and throws in two rows, false, kills everything.

Here's the annoying part. If the setSample function is called from the constructor and the default is true, it creates the columns and rows. If I set it to false and then set it back to true, I get the columns, but no rows.

Now here's the weird part. I thought I'd not destroy the data when set to false, and really do nothing. The rows disappeared anyway!!!

Now here's the compeltely totally bizarre part. I tried to debug things with trace and the dataProvider, and that made the entire component blank, just by adding some traces!!! What the heck is going on?!?!!?

Here's the code for setSample():

// Sets up a sample

private function setSample() {

trace('before');
trace(this.dataProvider);

if (_sample) {

this.addColumn("apple");
this.addColumn("orange");

this.addItem({apple:"Golden", orange:"Florida"});
this.addItem({apple:"McIntosh", orange:"California"});

} else {

this.removeAllColumns();

}

trace('after');
trace(this.dataProvider);

}

Oh, this is just in a class that extends the DataGrid class and adds some internal vars, getter/setters. So it's no big deal. I"m just wondering if I'm setting the DataGrid values wrong or it's a authoring/run time thing.

Thanks a bunch,

Gaf

gaf3
02-08-2005, 05:50 AM
Figured it out. The problem was the DataGrid extends the List component. The List component has Inspectable properties for labels and data, which I assume interacts with the addItem functions of the dataProvider. Since the data and labels are in a different format (id,labels vs. objects), the getter/setter stuff was mucking up the the dataProvider.

So all I had to do was override the getter/setter for labels and data and make them do nothing:

// Kill the data and labels stuff.

[Inspectable(defaultValue='', type='Array'))]
public function set labels(nLabels:Array):Void {

}

public function get labels():Array {

return [];

}

[Inspectable(defaultValue='', type='Array'))]
public function set data(nData:Array):Void {

}

public function get data():Array {

return [];

}

I also did the onUpdate thing and it creates the sample data always when in authoring mode, but doesn't at run time. I figured I'll always want to see what things look like when authoring, so what the heck.

Gaf