Moviri / recline

A simple but powerful library for building data applications in pure Javascript and HTML.
http://reclinejs.com/
MIT License
2 stars 2 forks source link

Filters don't work on virtual model #19

Closed scriminaci closed 12 years ago

scriminaci commented 12 years ago

Error returned

VModel - query for undefined virtualmodel.js (riga 314) TypeError: this._store is undefined

this._store.query(actualQuery, this.toJSON())

Code

var url, dataset, virtualdatasetAge;

url = "http://192.168.100.133:8380/cwwh-iwal-war/cw/wh/ds/AudDemoByGender";

dataset = new recline.Model.Dataset({
    //records: []
    url: url, //+"&jsonpcallback=jsonpcallback",
    backend: 'jsonp',
    id: "AudDemoByGender"

});

var filter = [{
    field: "daydate",
    type: "range",
    start: "2012-01-01 00:00:00",
    stop: "2012-01-07 00:00:00",
    fieldType: "date"
}];
virtualdatasetAge = new recline.Model.VirtualDataset({
    dataset: dataset,
    aggregation: {
        dimensions: ["age"],
        aggregatedFields: ["totalviewed", "price_sum"],
        partitions: ["gender"]
    }
});

var filter2 = [{
    field: "age",
    type: "range",
    start: "0",
    stop: "100",
    fieldType: "number"
}];

dataset.queryState.setFilter(filter);
virtualdatasetAge.queryState.setFilter(filter2);
davidemalagoli commented 12 years ago

works with:

var filterx = { field: "age", type: "term", term: "15", fieldType: "number" };

    filters = [ {field: "daydate", type: "range", start:"2012-01-01 00:00:00", stop: "2012-01-30 00:00:00", fieldType: "date", controlType: "range_calendar" }];
    for(var i=0;i<filters.length;i++)
        dataset.queryState.addFilter(filters[i]);

    virtualdatasetAge.queryState.addFilter(filterxx);
    dataset.fetch(); // needed to populate filter list