DataDriver.jsarray

class webix.DataDriver.jsarray()

Datadriver.jsarray mixin

External references

Official documentation page.

Code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
webix.DataDriver.jsarray={
    //parse jsarray string to jsarray object if necessary
    toObject:function(data){
        if (typeof data == "string")
            return JSON.parse(data);
        return data;
    },
    //get array of records
    getRecords:function(data){
        if (data && data.data)
            data = data.data;
        return data;
    },
    //get hash of properties for single record, in case of array they will have names as "data{index}"
    getDetails:function(data){
        var result = {};
        for (var i=0; i < data.length; i++)
         result["data"+i]=data[i];
        if (this.idColumn !== null)
            result.id = data[this.idColumn];

        return result;
    },
    getOptions:function(){ return false; },
    //dyn loading is not supported by js-array data source
    getInfo:function(data){
        return {
            size:0,
            from:0
        };
    },
    idColumn:null
};