2 Replies Latest reply on Aug 4, 2006 1:36 AM by pumakino

    Xml data fails to bind to Datagrid


      I am returning an XmlDocument from a .NET webservice and tyring to bind the result to the Datagrid. The code is pasted below :

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute"
      creationComplete="kino.GetOurOfficeList_NoSec.send()" >
      <mx:WebService id="kino"
      wsdl=" http://misdevservices/wsCommon/Options.asmx?wsdl"
      <mx:operation name="SayHello" resultFormat="xml"></mx:operation>
      <mx:operation name="GetOurOfficeList_NoSec" resultFormat="xml"></mx:operation>

      <mx:Panel x="21" y="10" width="500" height="400" layout="absolute" title="Hello World Test">

      <mx:DataGrid x="28" y="71" id="dgTopPosts" width="400" dataProvider="{kino.GetOurOfficeList_NoSec.lastResult.NewDataSet.OfficeList}">
      <mx:DataGridColumn headerText="OfficeName" dataField="OfficeName" />
      <mx:DataGridColumn headerText="Type" dataField="prefix" />

      <mx:Button id="debugButton" label="Trace" click="trace(kino.GetOurOfficeList_NoSec.lastResult.valueOf())">

      import mx.utils.ArrayUtil;


      When i am debugging the application, the following warning is generated : warning: unable to bind to property 'NewDataSet' on class 'Array' (class is not an IEventDispatcher)

      I added the trace and the Xml from the result is as follows:

      <GetOurOfficeList_NoSecResponse xmlns=" http://tempuri.org/WSCommon/" xmlns:xsd=" http://www.w3.org/2001/XMLSchema"
      xmlns:soap=" http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance">
      <NewDataSet xmlns="">

      I dont understand what I am doing wrong. I also tried changing the resultFormat of the operation to Object and adding the setting the datasource of the datagrid as follows :
      dataProvider="{mx.utils.ArrayUtil.toArray(kino.GetOurOfficeList_NoSec.lastResult.NewDataS et.OfficeList)}"

      That did nothing. Help would be greatly appreciated.
        • 1. Re: Xml data fails to bind to Datagrid
          ntsiii Level 3
          I am pretty sure that the cell renderer does not understand the dataField setting.

          The way you are doing this, you have an old-school xml object, now called XMLDocument. With this object, you cannot "dot-down" to child nodes.

          If you really want to use this obsolete object, you will need to use a label function. I can post an example if you want.

          Otherwise, specify the resultFormat="e4x". That may work immediately for yout.

          • 2. Re: Xml data fails to bind to Datagrid
            pumakino Level 1
            Hi Tracy,

            Thanks a lot for replying to my post. I did follow your suggestion and changed the result format to 'e4x' but this is what the trace says :

            warning: unable to bind to property 'NewDataSet' on class 'XMLList' (class is not an IEventDispatcher)
            warning: unable to bind to property 'OfficeList' on class 'XMLList' (class is not an IEventDispatcher)

            I did not make any changes to the rest of the code so it was the same as posted above the only difference being the resultformat. I would really appreciate it if you could post me an example.

            Another question which is related to this, since I am using .NET webservice, would it make a difference if i returned a Dataset instead of XmlDocument?? I tried returning the dataset from the service and it still gave the same problem .

            Thanks in advance!