RSS
 

AdvancedDataGrid: Adventures in binding

18 Sep

Quick post on AdvancedDataGrid dataProviders.

If your using a HierarchicalData provider for you AdvancedDataGrid (Flex) binding changes may (will) not be picked up by the AdvancedDataGrid.

For example


<mx:AdvancedDataGrid id="grid" bottom="10" top="40" left="10"
designViewDataType="tree" width="379">
<mx:dataProvider>
<mx:HierarchicalData source="{grades}"
childrenField="assignments"/>
</mx:dataProvider>
<mx:columns>
<mx:AdvancedDataGridColumn headerText="Course" dataField="title"/>
<mx:AdvancedDataGridColumn headerText="Score" dataField="scoreString" width="80"/>
</mx:columns>
</mx:AdvancedDataGrid>

Won’t pickup the update to ‘grades’. Instead you’ll need to update the dataProvider itself…


var hd:HierarchicalData = new HierarchicalData();
hd.childrenField = "assignments";
hd.source = grades;
grid.dataProvider = hd;

 
4 Comments

Posted in Flex

 

Leave a Reply

 

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

 
  1. Salman

    September 19, 2008 at 8:06 am

    How about:

    grid.dataProvider.refresh();

    You could possibly take it further and try something like:

    BindSetter( function( obj:Object ):void { grid.dataProvider.refresh(); }, yourObject, “grades” );

     
  2. Joshua

    September 19, 2008 at 4:16 pm

    Salman,
    Thanks for the reply.

    No, with a HierarchicalData dataProvider neither

    grid.dataProvider.refresh();

    nor

    BindingUtils.bindSetter(function( obj:Object ):void { grid.dataProvider.refresh(); }, this, “grades”);

    will solve the issue.

    You can find more details @ http://bugs.adobe.com/jira/browse/FLEXDMV-1334?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel

     
  3. mani

    October 13, 2008 at 9:42 pm

    Joshua, thanks for the article!

    By the way, could you opensource the DynamicModules which in the follow source page?
    It is wonderful, and could help me a lot.

    http://www.joshuaostrom.com/demos/mortgagepipes/srcview/index.html

    Thanks~~

     
  4. Kazi

    November 15, 2008 at 5:26 pm

    Thanks Joshua,

    this really helped me!!!