Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Ravi on Aug 20, 2009 00:22
open dhtmlx forum
DHTMLX GRID

Hi!
I am getting XML in some other format using java web serivces.How could a customize code so that the format in which the grid support automaticaely get parseable in<row> ,<cell> format.is It any way to achieve throughJSON
Thanks;
Ravi Gopalani
Answer posted by Support on Aug 20, 2009 06:08
Answer posted by Ravi(ravigopa@cisco.com) on Aug 20, 2009 22:41
Hi!
      The link you send me is not fulfilling the requirement.My requirement is :Data will be available in XML in any format through web services.Lets say below mention format:
"<recipe name=\"bread\" prep_time=\"5 mins\" cook_time=\"3 hours\"> <title>Basic bread</title> <ingredient amount=\"8\" unit=\"dL\">Flour</ingredient> <ingredient amount=\"10\" unit=\"grams\">Yeast</ingredient> <ingredient amount=\"4\" unit=\"dL\" state=\"warm\">Water</ingredient> <ingredient amount=\"1\" unit=\"teaspoon\">Salt</ingredient> <instructions> <step>Mix all ingredients together.</step> <step>Knead thoroughly.</step> <step>Cover with a cloth, and leave for one hour in warm room.</step> <step>Knead again.</step> <step>Place in a bread baking tin.</step> <step>Cover with a cloth, and leave for one hour in warm room.</step> <step>Bake in the oven at 180(degrees)C for 30 minutes.</step> </instructions> </recipe> ";
Now I have to change into data grid support format.i.e rows-cell style...so I need to make customize code not  only for the above mention XML.I should right some generic code which should support all forms of XML data whether Tree Structure ....simple data.Please let me know.Its possible to right generic function which can support all forms of XML formats.
Thanks,
Ravi Gopalani
Answer posted by Supoport on Aug 21, 2009 02:14
You can use three-steps loading process

a) use dhtmlxAjax to fetch xml in your custom format to the client side
b) transform it to the necessary format ( xslt transformation through the same dhtmlxAjax object is possible )
c) load grid from result of conversion ( grid.parse ) 
Answer posted by Ravi on Aug 21, 2009 02:39
Hi !
          Can you please give me sample code.
Answer posted by Alex (support) on Aug 21, 2009 08:06

The example:

dhtmlxAjax.get(custom_xml,outputResponse);

function outputResponse(loader){
 if(!loader.xmlDoc) return
  xml_string = loader.doXSLTransToString(xslDoc,loader.xmlDoc)
  grid.parse(xml_string)
}



Answer posted by Ravi on Aug 23, 2009 22:22
Hi!
      I have tried sample code but getting error:
Below mention is the sample code:
 dhtmlxAjax.get("<?xml version=\"1.0\"?><details><person created=\"2006-11-11T19:23\" modified=\"2006-12-31T23:59\">\n <firstName>Robert</firstName>\n <lastName>Smith</lastName>\n <address type=\"home\">\n <street>12345 Sixth Ave</street>\n <city>Anytown</city>\n <state>CA</state>\n <postalCode>98765-4321</postalCode>\n </address>\n </person> <person created=\"2006-11-11T19:23\" modified=\"2006-12-31T23:59\">\n <firstName>Robert</firstName>\n <lastName>Smith</lastName>\n <address type=\"home\">\n <street>12345 Sixth Ave</street>\n <city>Anytown</city>\n <state>CA</state>\n <postalCode>98765-4321</postalCode>\n </address>\n </person></details>",loadXmlData);


 }
 function loadXmlData(loader){
  
 if(!loader.xmlDoc) return
  xml_string = loader.doXSLTransToString("<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"></xsl:stylesheet>",loader.xmlDoc)
  grid.parse(xml_string)
}


Please let me know where I m doing a mistake
Answer posted by Alex (support) on Aug 24, 2009 06:42

Hello

Ajax loads data from server and get() method requires path to xml file (or to server-side page that genarates xml stream): dhtmlxAjax("some.xml",handler);

You've tried to use get method with xml string instead of file. You can create xmlObject from the xml string and then using xsl tranformation to load data to the grid.

A ready solution for transformation can be done only by additional fee. If you are insterested in it, please contact us at sales@dhtmlx.com 

Answer posted by Ravi on Aug 24, 2009 23:14
Hi!
      Cisco is using licensed version only.So It will be helpful,if you send me the proper solution at this mail id: ravigopa@cisco.com.
Thanks,
Ravi Gopalani