UNPKG

jqwidgets-framework

Version:

jQWidgets is an advanced Angular, Vue, Blazor, React, Web Components, jquery, ASP .NET MVC, Custom Elements and HTML5 UI framework.

98 lines (89 loc) 3.81 kB
<!DOCTYPE html> <html lang="en"> <head> <title id='Description'>This example shows how to bind the jqxDataAdapter to Comma-delimited text also known as comma-separated values (CSV).</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/nasdaq_vs_sp500.txt'; var source = { datatype: "csv", datafields: [ { name: 'Date', type: 'date' }, { name: 'S&P 500', type: 'float' }, { name: 'NASDAQ', type: 'float' } ], url: url }; 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>" html += "<th>Date</th>" html += "<th>S&P 500</th>" html += "<th>NASDAQ</th>" html += "</tr>"; for (var i = 0; i < 20; i++) { var record = records[i]; html += "<tr>"; html += "<td>" + dataAdapter.formatDate(record["Date"], 'D') + "</td>"; html += "<td>" + record["S&P 500"] + "</td>"; html += "<td>" + record["NASDAQ"] + "</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>