We have updated WebDataRocks EULA, effective as of April 18, 2024. Learn more about what's changed.
Documentation menu

runQuery

runQuery(query:Query Object)

Invoke this method on a pivot table instance. It takes a Query Object as an argument and runs it. The Query Object contains a slice with rows, columns, measures, and reportFilters.

Use it if you need to:

  • reorganize the hierarchies on the grid.
  • compose a new report that is based on the current data.

Parameters

NameTypeDescription
queryQuery ObjectContains rows, columns, measures, and reportFilters from a Slice Object.

Example

Suppose you have a pivot table with the following report:

var pivot = new WebDataRocks({
    container: "wdr-component",
    toolbar: true,
    report: {
        "dataSource": {
            "filename": "https://cdn.webdatarocks.com/data/data.csv"
        },
        "slice": {
            "rows": [{
                "uniqueName": "Category"
            }],
            "columns": [{
                    "uniqueName": "Measures"
                },
                {
                    "uniqueName": "Country"
                }
            ],
            "measures": [{
                "uniqueName": "Price",
                "aggregation": "sum"
            }]
        }
    }
});

If you want to rearrange the hierarchies in a slice dynamically with code, define the following slice and pass it as an argument to the runQuery() method:

var slice = {
    "rows": [{
        "uniqueName": "Country"
    }],
    "columns": [{
        "uniqueName": "Category"
    }],
    "measures": [{
        "uniqueName": "Price",
        "aggregation": "sum"
    }]
};
webdatarocks.runQuery(slice);

Check out more details in the CodePen demo.

See also