Author Topic: Grids populated with XML data  (Read 2636 times)

lgauton

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 44
    • View Profile
Grids populated with XML data
« on: March 13, 2014, 09:10:09 pm »
Hi

I have a number of XML documents that I want to populate grids with, the documents are all similar to this structure

<?xml version="1.0"?>
<ArrayOfContact xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Contact>
   <id xmlns="http://xxxxxx.co.uk/td2/frontend/contractsmanager">116035291</id>
   <type xmlns="http://xxxxxx.co.uk/td2/frontend/contractsmanager">
      <code>COMMMANGER</code>
      <description>Commercial Manager</description>
   </type>
   <name xmlns="http://xxxxxx.co.uk/td2/frontend/contractsmanager">Mr Francis Drake</name>
</Contact>
<Contact>
   <id xmlns="http://xxxxxx.co.uk/td2/frontend/contractsmanager">116035292</id>
   <type xmlns="http://xxxxxx.co.uk/td2/frontend/contractsmanager">
      <code>DUTYOFF</code>
      <description>Duty Officer</description>
   </type>
   <name xmlns="http://xxxxxx.co.uk/td2/frontend/contractsmanager">Miss Katie Price</name>
</Contact>
</ArrayOfContact>

the xml populates OK (see attached grid), except for lookup type fields as example 'type' above where the xml gives both code and description, xml definition I use in the grid is

var obj = { itemParent: "Contact", itemNames: ["id", "type", "name"] };

var colModel = [
                { title: "ID", dataType: "string", width: "75", dataIndx: 0 },
                { title: "Type", dataType: "string", width: "250", dataIndx: 1 },
                { title: "Name", dataType: "string", width: "250", dataIndx: 2 }
                ];

is there a way I can either

1. Change the xml definition to handle the lookup fields, better and be able to reference the 'code' and 'description'
2. Extract from current grid just the part relating to the 'code' element

Thanks


paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Grids populated with XML data
« Reply #1 on: March 13, 2014, 11:40:57 pm »
you can still reference code and description as:

var obj = { itemParent: "Contact", itemNames: ["id", "type", "name", "code", "description" ] };