2 Replies Latest reply on Oct 29, 2009 10:37 AM by Mike6679

    XMLList For Datagrid




      I'm using EX4 to search XML and then trying to populate my datagrid. Easy enough. Howerver. I can't figure out hhow to get the "name" node to show up in my results. Its the "name" node I'm searching on and in the results, its the root node. How can I get that node into my "Category" column?? Do I have to manually insert it into each row....but then how do I do that because in a datagrid you have to populate an entire row at once, you just can't populate one cell right?


      //// XML ////////



      <category name="TOXICOLOGY">

      <keywords>  Digoxin  </keywords>
      <code> 972.1 </code>

      <keywords>  Immunosuppressive agents  </keywords>
      <code> 963.1 </code>

      <keywords>  After care for Immunosuppressive agents  </keywords>
      <code>  V58.69  </code>







      /////// Datagrid ///////

      <mx:DataGrid x="0" y="88" width="400" height="368"  id="datagrid_codes">
                  <mx:DataGridColumn headerText="Keyword" dataField="keywords"/>
                  <mx:DataGridColumn headerText="Category" dataField="name"/>
                  <mx:DataGridColumn headerText="Code" dataField="code"/>



      /////  code to search  ///////////


      m_xml_list = m_theFullXML.category.(@name == string  );

      m_datagridCodes.dataProvider = m_xml_list.children();

        • 1. Re: XMLList For Datagrid
          paul.williams Level 4

          Perhaps you could set-up a labelFunction on your Category column and return the currently selected name from that?


          http://livedocs.adobe.com/flex/3/langref/mx/controls/dataGridClasses/DataGridColumn.html#l abelFunction

          • 2. Re: XMLList For Datagrid
            Mike6679 Level 1

            Thanks Paul. I didn't try your suggestion because I found a workaround by using an array



            public function search(string:String,category:Boolean):void
                            m_xml_list = m_theFullXML.category.(@name == string  );
                            m_datagridCodes.dataProvider = m_xml_list.children();
                            //we know the category so lets populate it as well..
                            //poulate array with new row item data
                            var dp:Array = new Array();
                            for (var idx:int =0 ;idx < IList(m_datagridCodes.dataProvider).length ; ++idx)
                                var ObjOrig:Object = IList(m_datagridCodes.dataProvider).getItemAt(idx);
                                var ItemSourceObjFinal:Object = {keywords: ObjOrig.keywords  ,
                                                                 name: string ,
                                                                 code: ObjOrig.code };
                            m_datagridCodes.dataProvider = dp;