Initialization

To initialize dhtmlxDataView on a page, you need to take the following simple steps:

<!DOCTYPE html>
<html>
    <head>
        <title>How to Start with dhtmlxDataView</title>         
        <script type="text/javascript" src="../../codebase/suite.js"></script>
        <link rel="stylesheet" href="../../codebase/suite.css">
    </head>
    <body>
        <div id="dataview_container"></div>
        <script>
            // creating dhtmlxDataView
            var dataview = new dhx.DataView("dataview_container",{
                itemsInRow: 5
            });
</script> </body> </html>

Related sample:  Dataview. Basic Initialization

Include source files

Create an HTML file and place full paths to JS and CSS files of the dhtmlxSuite library into the header of the file. The files are:

  • suite.js
  • suite.css
<script type="text/javascript" src="../../codebase/suite.js"></script>
<link rel="stylesheet" href="../../codebase/suite.css">

Create a container

Add a container for DataView and give it an id, for example "dataview_container":

index.html

<div id="dataview_container"></div>

Initialize DataView

Initialize DataView with the dhx.DataView object constructor. The constructor has two parameters:

  • the HTML container for DataView,
  • optional, an object with configuration properties (see the full list below). If this argument is not passed to the constructor, the settings will be default.

index.html

// creating dhtmlxDataView
var dataview = new dhx.DataView("dataview_container", {
    itemsInRow: 5
});

There is a set of properties you can specify for DataView to optimize its configuration for your needs. Read the details below.

Configuration properties

You can specify the following properties in the configuration object of DataView:

css adds a CSS class(es) to the component
data specifies an array of data objects to set into the dataview
dragCopy defines that an item is copied to a target during drag-n-drop
dragMode enables drag-n-drop in DataView
editable enables editing in DataView
gap sets margins for DataView items
height sets the height of Dataview
itemHeight sets the height of an item
itemsInRow specifies the number of data items in a row
keyNavigation enables/disables navigation in DataView by arrow keys
multiselection enables selection of multiple DataView items
template specifies a template for DataView items

Load data into DataView

Finally, you are to load DataView with data. You can load inline or external data into DataView.

  • to load data from a local source, use the parse method of the Data Collection object:
var dataview = new dhx.DataView("dataview_container",{
     itemsInRow: 5
});
 
dataview.data.parse(data);
  • to load data from an external file, use the load method of the Data Collection object:
var dataview = new dhx.DataView("dataview_container",{
    itemsInRow: 5
});
 
dataview.data.load("../common/dataset.json");

Related sample:  Dataview. Basic Initialization

Back to top