I'm trying to get a better understanding of how the Spark DataGrid component works so that I can create and extended version for one of my projects. One of the things that really has me stumped is how the datagrid sets up the columns based on the dataprovider when no explicit columns are defined. I've been able to debug through the datagrid initialization up to the point where the setter for dataprovider gets called. At that point my debug trace goes 'down the rabbit hole' so to speak, and when it comes back the columns are initialized but I can't figure out how. Could someone please point me to the Class/function that is actually responsible for creating the columns from the dataprovider if they are not defined explicitly?
I finally managed to track down the code I needed, it's in the commitProperties method of Grid.as (line 3555). That's the good news. The bad news is I still seem to be missing something. My understanding was, if the datagrid autogenerated the columns, those columns would be replaced if another collection of columns are defined for the datagrid at some later point. For some reason that doesn't seem to be happening for me.
The datagrid I'm working with is part of a larger component with a skin. The list of columns for the datagrid is bound to an ArrayList defined in the hostComponent of the skin. I can understand why the creation of the columns could happen before the binding from the host triggers, what I don't get is why they aren't overridden later. Any suggestions?
So, as you've discovered, the private Grid/generateColumns() method is called if the columns list is still null at commitPropertes() time. Subsequent changes to the columns property, even as a consequence of binding, should update the colums list as expected.
Could you create an example that demonstrates the problem you've run into? I'd be happy to look at it.
- Hans
North America
Europe, Middle East and Africa
Asia Pacific