JSArray

Initial Data

As initial data we'll take 3 books:

  • “War and Peace” by Leo Tolstoy
  • “Hamlet” by William Shakespeare
  • “Madame Bovary” by Gustave Flaubert

Configuration

In JSArray the data will look as:

books.js

[
 ["War and Peace", "Leo Tolstoy" ],
 ["Hamlet", "Shakespeare" ],
 ["Madame Bovary", "Gustave Flaubert" ]
]

Data in JS array hasn’t got names for values. Values are accessible as (“data0”, “data1”, …):

HTML Code

list(jsarray).html

<!DOCTYPE HTML>
<html>
	<head>
	<link rel="stylesheet" href="../../../codebase/touchui.css" type="text/css" media="screen" charset="utf-8">
		<script src="../../../codebase/touchui.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
              <script type="text/javascript" charset="utf-8">
 
              var books = [
                           ["War and Peace", "Leo Tolstoy" ],
                           ["Hamlet", "Shakespeare" ],
                           ["Madame Bovary", "Gustave Flaubert" ]
                          ]
	      dhx.ui({
                    view:"list",
                    data:"books", 
                    datatype:"jsarray",
		    template:"#data0# (#data1#)", 
                    select:true, 
                    type: {width: 300}
              });    
	      </script>
 
	</body>
</html>

If you use data from external file - remove the data parameter and add url, where specify the desired data file.

dhx.ui({
                    view:"list",
                    url:"books.js", 
                    datatype:"jsarray",
		    template:"#data0# (#data1#)", 
                    select:true, 
                    type: {width: 300}
});