jqwidgets-framework
Version:
jQWidgets is an advanced Angular, Vue, Blazor, React, Web Components, jquery, ASP .NET MVC, Custom Elements and HTML5 UI framework.
104 lines (97 loc) • 4.51 kB
HTML
<html lang="en">
<head>
<title id='Description'>This example shows how to bind the jqxDataAdapter to XML.</title>
<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>
<style type="text/css">
table {
font-family: verdana,arial,sans-serif;
font-size: 11px;
color: #333333;
border-width: 1px;
border-color: #666666;
border-collapse: collapse;
}
table th {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #666666;
background-color: #dedede;
}
table td {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #666666;
background-color: #ffffff;
}
</style>
<script type="text/javascript">
$(document).ready(function () {
var url = "../../sampledata/orders.xml";
// prepare the data
var source =
{
datatype: "xml",
datafields: [
{ name: 'ShippedDate', map: 'm\\:properties>d\\:ShippedDate', type: 'date' },
{ name: 'Freight', map: 'm\\:properties>d\\:Freight', type: 'float' },
{ name: 'ShipName', map: 'm\\:properties>d\\:ShipName' },
{ name: 'ShipAddress', map: 'm\\:properties>d\\:ShipAddress' },
{ name: 'ShipCity', map: 'm\\:properties>d\\:ShipCity' },
{ name: 'ShipCountry', map: 'm\\:properties>d\\:ShipCountry' }
],
root: "entry",
record: "content",
id: 'm\\:properties>d\\:OrderID',
url: url,
pager: function (pagenum, pagesize, oldpagenum) {
// callback called when a page or page size is changed.
}
};
var dataAdapter = new $.jqx.dataAdapter(source, {
loadComplete: function () {
// get data records.
var records = dataAdapter.records;
// get the length of the records array.
var length = records.length;
// loop through the records and display them in a table.
var html = "<table border='1'><tr><th align='left'>Freight</th><th align='left'>Ship Name</th><th align='left'>Ship Address</th><th align='left'>ShipCity</th><th align='left'>Ship Country</th></tr>";
for (var i = 0; i < 20; i++) {
var record = records[i];
html += "<tr>";
html += "<td>" + record.Freight + "</td>";
html += "<td>" + record.ShipName + "</td>";
html += "<td>" + record.ShipAddress + "</td>";
html += "<td>" + record.ShipCity + "</td>";
html += "<td>" + record.ShipCountry + "</td>";
html += "</tr>";
}
html += "</table>";
$("#table").html(html);
},
loadError: function (jqXHR, status, error) {
},
beforeLoadComplete: function (records) {
}
});
// perform data binding.
dataAdapter.dataBind();
});
</script>
</head>
<body class='default'>
<div id="table">
Loading...
</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>