jQWidgets Forums
jQuery UI Widgets › Forums › Grid › JqxGrid with XML
Tagged: jqxGrid with XML
This topic contains 3 replies, has 2 voices, and was last updated by hh_shan 12 years, 4 months ago.
-
AuthorJqxGrid with XML Posts
-
Hi,
First of all I would like to say the product you are having here is great and it has made my work very easy. Its the first time though am using the jjqxGrid and I ran into and issue. I was trying to load this c# generated XML to jqxGrid but I am alittle bit confused as the formats of the XML from your examples and generated XML files are very much different. The generated the XML is as follows,<?xml version="1.0" encoding="utf-8"?><ArrayOfAnyType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <anyType xsi:type="Confidence"> <Ip>124.43.211.68</Ip> <Count>8</Count> <Isp /> <TimeStamp>2012-10-02 01:00</TimeStamp> <Port>33354</Port> <ForeignGeo>FI</ForeignGeo> </anyType> <anyType xsi:type="Confidence"> <Ip>175.157.160.121</Ip> <Count>8</Count> <Isp /> <TimeStamp>2012-10-02 01:00</TimeStamp> <Port>3020</Port> <ForeignGeo>DE</ForeignGeo> </anyType> <anyType xsi:type="Confidence"> <Ip>122.255.34.37</Ip> <Count>8</Count> <Isp>mail.sumithra.lk</Isp> <TimeStamp>2012-10-02 01:01</TimeStamp> <Port /> <ForeignGeo /> </anyType> <anyType xsi:type="Confidence"> <Ip>103.247.48.149</Ip> <Count>8</Count> <Isp /> <TimeStamp>2012-10-02 01:02</TimeStamp> <Port /> <ForeignGeo>NL</ForeignGeo> </anyType> <anyType xsi:type="Confidence"> <Ip>112.135.132.188</Ip> <Count>8</Count> <Isp>SLT-BB-CUST.slt.lk</Isp> <TimeStamp>2012-10-02 01:02</TimeStamp> <Port /> <ForeignGeo>NL</ForeignGeo> </anyType> <anyType xsi:type="Confidence"> <Ip>103.247.49.154</Ip> <Count>8</Count> <Isp /> <TimeStamp>2012-10-02 01:03</TimeStamp> <Port /> <ForeignGeo /> </anyType> <anyType xsi:type="Confidence"> <Ip>122.255.34.146</Ip> <Count>8</Count> <Isp /> <TimeStamp>2012-10-02 01:03</TimeStamp> <Port /> <ForeignGeo /> </anyType></ArrayOfAnyType>
May I know how to load these data jqxGrid. Thank you very much
Hi hh_shan,
Here is a sample which loads the Grid from your XML. In the code “data.xml” is a file with the posted xml.
<!DOCTYPE html><html lang="en"><head> <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" /> <script type="text/javascript" src="../../scripts/jquery-1.8.2.min.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxdata.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxbuttons.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxscrollbar.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxmenu.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxgrid.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxgrid.selection.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxgrid.columnsresize.js"></script> <script type="text/javascript" src="../../scripts/gettheme.js"></script> <script type="text/javascript"> $(document).ready(function () { var theme = getDemoTheme(); // prepare the data var source = { datatype: "xml", datafields: [ { name: 'Ip', type: 'string' }, { name: 'Count', type: 'int' }, { name: 'Isp', type: 'string' }, { name: 'TimeStamp', type: 'date' }, { name: 'Port', type: 'int' }, { name: 'ForeignGeo', type: 'string' } ], root: "ArrayOfAnyType", record: "anyType", async: false, url: "data.xml" }; var dataAdapter = new $.jqx.dataAdapter(source); // Create jqxGrid $("#jqxgrid").jqxGrid( { width: 670, source: dataAdapter, theme: theme, columnsresize: true, columns: [ { text: 'Ip', datafield: 'Ip', width: 250 }, { text: 'Count', datafield: 'Count', width: 150 }, { text: 'Isp', datafield: 'Isp', width: 180 }, { text: 'TimeStamp', datafield: 'TimeStamp', width: 120 }, { text: 'Port', datafield: 'Port', width: 90 }, { text: 'ForeignGeo', datafield: 'ForeignGeo', width: 100 } ] }); }); </script></head><body class='default'> <div id='jqxWidget' style="font-size: 13px; font-family: Verdana; float: left;"> <div id="jqxgrid"></div> </div></body></html>
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi Peter,
Thank you very much for the help
i will try this out and will post back..very much appreciated
Thank you very much for the help it worked!!
sorry for the late reply as I was out of town
-
AuthorPosts
You must be logged in to reply to this topic.