--- In [email protected], "Mike" <msl...@...> wrote:
>
> I must take the DataGrid as I find it.  If no labelFunction is defined, that 
> approach won't work; also each item in the dataProvider might be manifested 
> in 0 or more columns.  This approach probably won't be general enough.

Do you have enough control in the project to ask that the Value Objects in the 
DataProvider implement a common interface?  Then just have a getter defined by 
the interface that says what the rendered row should look like.

I haven't had good luck instantiating renderers by hand, especially ones that 
fully implement IDropInListItemRenderer, and you're goingto run into several 
problems trying to do this:

1) Performance: Creating an object is usually the biggest processor hit.  
Multiply this across multiple columns, and you are likely to have a slowdown.
2) Timing: It's not like you can just create the renderers and immediately 
start reading through them for text.  You'll need to wait until everthing is 
complete and all the properties are set, so you're going to have to pass things 
back and forth between multiple event handlers.
3) Depth: Since you have no control over the renderers, you don't have any way 
of knowing whether they're composed of containers within containers, etc.
4) Layout: Presumably, you want to have the text appear in the same order it 
appears in the columns, and then within the individual renderers.  There's no 
guarantee that your iteration will go from top left to bottom right, so you'll 
have to record where the text was found and then arrange it in some way that 
tries to make sense (but may not, depending on what is going on in the 
renderers).
5) Random surprises from the renderer developers.  If the renderer developer 
makes a reference to its parent, owner, or something else like that and you 
instantiate it in a way that doesn't involve a List of some sort, you may wind 
up with Null Pointer Exceptions.  They may come up with other stuff that won't 
come up in your testing with reasonable renderers that you wrote, but it will 
be your fault when they do something stupid and YOUR logic errors out.

In short, you have to work together with your other team members one way or 
another to make this work.  Why not just shortcut to the most performant method?

-Amy

Reply via email to