3 Replies Latest reply on May 8, 2007 12:38 AM by M. Huisman

    Data Binding Trouble

    M. Huisman Level 1
      I'm trying to create a dynamic databinding to my model, but delimiter it's binding by comparing id's:

      So I've got a structure like this:

      (model.)
      dataCustomer.
      --------------------Customer. (@id)
      ----------------------------------Communications.
      ----------------------------------------------------------Communication. (@id)

      (model.)
      Customerid

      (model.)
      Communication. (@id @type)

      Now I want to achieve databinding on a textfield.

      <mx:TextInput
      x="125.5"
      y="79"
      editable="{model.editmode}"
      text="{model.dataCommunication.Communication.(@id in model.dataCustomer.Customer.(@id == model.Customerid).Communications.Communication.@id).(@type == 'Website')}"
      borderStyle="{model.editlines}"
      id="txtWebsite"/>

      The funny thing is, if I trace() the field (without the @type) I only get four (id's 0123) of my results, while there are a lot more of them in my model and the ones coupled to that customerid are (id's 0234).

      So I'm wondering what I am doing wrong, so anyone inhere who sees my error?

        • 1. Re: Data Binding Trouble
          M. Huisman Level 1
          Ok, I'm a little step further, it seems that flex uses the number of subnodes in my Communications node to calculate the number of children it takes in account, is there a workaround for this?
          • 2. Re: Data Binding Trouble
            M. Huisman Level 1
            nobody?
            • 3. Re: Data Binding Trouble
              M. Huisman Level 1
              Ok i fixed half.. i'll post my code to help you all..

              public static function fetch(type:String) {
              var model:ModelLocator = ModelLocator.getInstance();
              for each (var item in model.dataCustomer.Customer) {
              if (item.@id == model.Customerid) {
              for each (var subitem in item.(@id == model.Customerid).Communications.Communication.@id) {
              if (model.dataCommunication.Communication.(@id == subitem).@type == type) {
              return subitem;
              }

              }

              }
              }
              }

              <mx:TextInput
              x="125.5"
              y="33"
              editable="{model.editmode}"
              text="{model.dataCommunication.Communication.(@id == XMLHandling.fetch('Fax'))}"
              borderStyle="{model.editlines}"
              id="txtFax"/>