UNPKG

jqwidgets-scripts-custom

Version:

jQWidgets is an advanced jQuery, Angular 7, Vue, React, ASP .NET MVC, Custom Elements and HTML5 UI framework.

142 lines (134 loc) 5.33 kB
<!DOCTYPE html> <html lang="en"> <head> <title id='Description'>Tree Custom Element JSONTree</title> <meta name="description" content="This is an example of the Tree Custom Element bound to JSON." /> <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" /> <link rel="stylesheet" href="../../../jqwidgets/styles/jqx.base.css" type="text/css" /> <link rel="stylesheet" href="../../../styles/demos.css" type="text/css" /> <script type="text/javascript" src="../../../scripts/webcomponents-lite.min.js"></script> <script type="text/javascript" src="../../../jqwidgets/jqxcore.js"></script> <script type="text/javascript" src="../../../jqwidgets/jqxcore.elements.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/jqxpanel.js"></script> <script type="text/javascript" src="../../../jqwidgets/jqxtree.js"></script> <script src="../../../scripts/demos.js"></script> <script type="text/javascript"> var data = [ { 'id': '2', 'parentid': '1', 'text': 'Hot Chocolate', 'value': '$2.3' }, { 'id': '3', 'parentid': '1', 'text': 'Peppermint Hot Chocolate', 'value': '$2.3' }, { 'id': '4', 'parentid': '1', 'text': 'Salted Caramel Hot Chocolate', 'value': '$2.3' }, { 'id': '5', 'parentid': '1', 'text': 'White Hot Chocolate', 'value': '$2.3' }, { 'text': 'Chocolate Beverage', 'id': '1', 'parentid': '-1', 'value': '$2.3' }, { 'id': '6', 'text': 'Espresso Beverage', 'parentid': '-1', 'value': '$2.3' }, { 'id': '7', 'parentid': '6', 'text': 'Caffe Americano', 'value': '$2.3' }, { 'id': '8', 'text': 'Caffe Latte', 'parentid': '6', 'value': '$2.3' }, { 'id': '9', 'text': 'Caffe Mocha', 'parentid': '6', 'value': '$2.3' }, { 'id': '10', 'text': 'Cappuccino', 'parentid': '6', 'value': '$2.3' }, { 'id': '11', 'text': 'Pumpkin Spice Latte', 'parentid': '6', 'value': '$2.3' }, { 'id': '12', 'text': 'Frappuccino', 'parentid': '-1' }, { 'id': '13', 'text': 'Caffe Vanilla Frappuccino', 'parentid': '12', 'value': '$2.3' }, { 'id': '15', 'text': '450 calories', 'parentid': '13', 'value': '$2.3' }, { 'id': '16', 'text': '16g fat', 'parentid': '13', 'value': '$2.3' }, { 'id': '17', 'text': '13g protein', 'parentid': '13', 'value': '$2.3' }, { 'id': '14', 'text': 'Caffe Vanilla Frappuccino Light', 'parentid': '12', 'value': '$2.3' } ]; var source = { datatype: 'json', datafields: [ { name: 'id' }, { name: 'parentid' }, { name: 'text' }, { name: 'value' } ], id: 'id', localdata: data }; var dataAdapter = new jqx.dataAdapter(source, { autoBind: true }); var records = dataAdapter.getRecordsHierarchy('id', 'parentid', 'items', [{ name: 'text', map: 'label' }]); JQXElements.settings['treeSettings'] = { source: records }; </script> </head> <body> <div class="example-description"> In this demo the Tree Custom Element is built from JSON data. </div> <jqx-tree settings="treeSettings"></jqx-tree> </body> </html>