Skip to main content

Data loading

There are several ways of loading DataView items:

  • on initialization of DataView
  • after initialization of DataView

First, you need to prepare a data set that will be loaded into DataView.

Preparing data set

DHTMLX DataView expects loaded data in the JSON format. Here is an example of an appropriate data set:

const dataset = [
"value": "Ben",
"short": "Ben is a very cautious 5-year-old Siberian Husky.",
"thumbnailName": "01.jpg"
"value": "Izzy",
"short": "This is our most beloved kingfisher bird Izzy.",
"thumbnailName": "02.jpg"
"value": "Momo",
"short": "Momo is a 25-year-old elephant with a big heart.",
"thumbnailName": "03.jpg"

Each object in the data set contains a number of key:value pairs that represent attributes of DataView items.


You can specify your own template of rendering DataView items with the help of the template configuration option.

Loading data on initialization

You can load a predefined data set into DataView on the initialization stage. Use the data configuration property, as in:

const dataview = new dhx.DataView("dataview_container", {
itemsInRow: 2,
gap: 10,
css: "dhx_widget--bordered",
template: template,
data: dataset

Related sample: Dataview. Initialization with

Loading data after initialization

There are two ways to load data into Combobox after its initialization:

External data loading

To load data from an external file, make use of the load() method of DataCollection. It takes the URL of the file with data as a parameter:

const dataview = new dhx.DataView("dataview_container");"../common/dataset.json");

Related sample: Dataview. Initialization with data.load()

The component will make an AJAX call and expect the remote URL to provide valid JSON data.

Data loading is asynchronous, so you need to wrap any after-loading code into a promise:"/some/data").then(function(){
// some logic here

Loading from local source

To load data from a local data source, use the parse() method of DataCollection. Pass a predefined data set as a parameter of this method:

const dataview = new dhx.DataView("dataview_container");;

Related sample: Dataview. Initialization with data.parse()

Saving and restoring state

To save the current state of a dataview, use the serialize() method of DataCollection. It converts the data of a dataview into an array of JSON objects. Each JSON object contains a set of key:value pairs that represent attributes of DataView items.

const state =;

Then you can parse the data stored in the saved state array to a different dataview. For example:

// creating a new dataview
const dataview2 = new dhx.DataView(document.body);
// parsing the state of dataview1 into dataview2;