jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Binding my XML Data to jQXGrid
This topic contains 1 reply, has 2 voices, and was last updated by Hristo 5 years, 5 months ago.
-
Author
-
Hello,
I need your help as I am fairly new to this. I have an ASP page that exports my recordset to an XML file. I’d like to read my XML file from this url: http://www.accdb.somee.com/gridview.xml and compile the data from into my grid.
What would the markup/coding be to get the data (FirstName, LastName, Floor & Office) into a jQXGrid?
I’ve tried the following, but the grid is still coming up empty:
<!DOCTYPE html> <html lang="en"> <head> <title id='Description'>This example shows how to create a Grid from XML data.</title> <meta name="description" content="JavaScript Grid data binding to XML data" /> <link rel="stylesheet" href="../../../jqwidgets/styles/jqx.base.css" type="text/css" /> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> <meta name="viewport" content="width=device-width, initial-scale=1 maximum-scale=1 minimum-scale=1" /> <script type="text/javascript" src="../../../scripts/jquery-1.12.4.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/demos.js"></script> <script type="text/javascript"> $(document).ready(function () { var url = "http://www.accdb.somee.com/gridview.xml"; // prepare the data var source = { datatype: "xml", datafields: [ { name: 'FirstName' }, { name: 'LastName' }, { name: 'Floor' }, { name: 'Office' } ], root: "rs\\:data", record: "z\\:row", url: url }; var dataAdapter = new $.jqx.dataAdapter(source); // Create jqxGrid $("#grid").jqxGrid( { width: getWidth('Grid'), source: dataAdapter, columnsresize: true, columns: [ { text: 'LastName', datafield: 'LastName', width: 250 }, { text: 'FirstName', datafield: 'FirstName', width: 150 }, { text: 'Floor', datafield: 'Floor', width: 180 }, { text: 'Office', datafield: 'Office', width: 120 } ] }); }); </script> </head> <body class='default'> <div id="grid"></div> <div style="position: absolute; bottom: 5px; right: 5px;"> <a href="https://www.jqwidgets.com/" alt="https://www.jqwidgets.com/"><img alt="https://www.jqwidgets.com/" title="https://www.jqwidgets.com/" src="https://www.jqwidgets.com/wp-content/design/i/logo-jqwidgets.png"/></a> </div> </body> </html>
Hello Buggs2015,
I saw that you have meaning content as attributes and for this purpose I would like to suggest you try on that way:
var source = { url: "http://www.accdb.somee.com/gridview.xml", datafields: [ { name: 'FirstName', type: 'string', map: "[FirstName]" }, { name: 'LastName', type: 'string', map: "[LastName]" }, { name: 'Floor', type: 'number', map: "[Floor]" }, { name: 'Office', type: 'string', map: "[Office]" } ], datatype: "xml", root: "rs\\:data", record: "z\\:row" };
We have a similar topic.
I hope this will help.Best Regards,
Hristo HristovjQWidgets team
https://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.