3 Replies Latest reply on Jul 30, 2007 5:17 AM by chris.huston.t10

    Datagrid troubles

    M. Huisman

      I’m having a little (big) problem with my Flex Sales Application, Somehow a datagrid doesn’t work the way I intend it to work.

      I’ve created a datagrid with databinding to my cairngorm model in this way:

      // Model Reference

      import com.nl4b.model.ModelLocator;
      public var model:ModelLocator = ModelLocator.getInstance();

      // Datagrid dataprovider

      <mx:DataGrid x="10" y="10" width="1100" id="dg" click="setSelIndex()" dataProvider="{model.dataContactperson.Contactperson.(@id == model.Customerid)}">
      <mx:DataGridColumn id="dcFirstname" dataField="Firstname" headerText="Voornaam"/>
      <mx:DataGridColumn id="dcMiddlename" dataField="Middlename" headerText="Tussenvoegsel" width="100"/>
      <mx:DataGridColumn id="dcLastname" dataField="Lastname" headerText="Achternaam"/>
      <mx:DataGridColumn id="dcPhone" dataField="Communicationid" labelFunction="getInfoById" headerText="Telefoonnummer"/>
      <mx:DataGridColumn id="dcMobile" dataField="Communicationid" labelFunction="getMobilenoById" headerText="Mobiel"/>
      <mx:DataGridColumn id="dcEmail" dataField="Communicationid" labelFunction="getEmailById" headerText="Email"/>

      This seems alright, and it works when I display my contactlist in display mode.

      Now comes the tricky part.

      If I create a new instance of my contactperson on the model (since it’s xml based this isn’t a big problem), the new instance won’t show up in the datagrid, even thought I’ve got my databinding set to my model.

      Can you help me find a suitable solution or a workaround that makes it possible to update (or refresh) the datagrid manually or using a local pointer to the model’s contactperson instance?

      Or am I overseeing something..

      Thanks in advance,