Initializing DataStore

Included files

To use the functionality of dhtmlXDataStore you need to include one file:

<script type="text/javascript" src="../codebase/datastore.js"></script>


Note, if you use the dhtmlxSuite package you needn't include any additional files.

Object constructor

There are 2 ways of initializing DataStore and filling it with data:

1) To create and then fill with script:

var myDataStore = new dhtmlXDataStore();
myDataStore.parse([
    {id:"1", name:"Accounts Department"},
    {id:"2", name:"Customer Service"},
    {id:"3", name:"Developing Department"}
]);

2) To specify the path to a data file in the constructor (fill from server):

var data = new dhtmlXDataStore({
    url:"data/data.json",
    datatype:"json"
});

Parameters

data (object)

The loaded data.

var contacts = new dhtmlXDataStore({  
    data:[
        {name: "Alex", gender:"male"}, 
        {name: "Kate", gender:"female"} 
    ]
});

dataFeed (string)

The path to php file which will get change requests. Used to reload data from server.

var contacts = new dhtmlXDataStore({  
    dataFeed:"../data/json.php",
    datatype:"json"
});

datatype

The type of data. (json, xml, jsarray, csv)

var contacts = new dhtmlXDataStore({  
    url:"data/data.json",
    datatype:"json"
});

scheme (object)

The default scheme for data records.

var contacts = new dhtmlXDataStore({  
    url:"data/data.json",
    datatype:"json",
    scheme({
        name:"Unknown",
        gender:"male",
        age:25,
        department: "Unknown"
    })
});

url (string)

The data url.

var contacts = new dhtmlXDataStore({  
    url:"data/data.json",
    datatype:"json"
});
Back to top