Get Free Trial

How to set DataSource from Ajax call

Bryan asked on July 24, 2018

I want to fill the pivot with data through the result of an ajax call
I’m trying something like this, but it does not work, does not load any data.

    var pivot = new Flexmonster({
        container: “pivot-container”,
        componentFolder: “”,
        global: {
            localization: “loc/es.json”
        width: “100%”,
        height: “600px”,
        report: {
            dataSource: {
                dataSourceType: “json”,
                data: getData()
slice: {
     rows: [{ uniqueName: “column1” }, { uniqueName: “column2” }],
                columns: [{ uniqueName: “[column3]” }],
                measures: [{ uniqueName: “column4” }]
//ajax call
//The function returns the data correctly.
    function getDatos() {
            type: “GET”,
            dataType: “json”,
            contentType: “application/json; charset=utf-8”,
            url: “api/data”,
            success: function (response) {
                return response;
if I use the url in Connect => To Remote JSON it work like a charm, which indicates that the json format is correct.
How can I load the data pivot using an ajax call?

2 answers

Tanya Gryshko Tanya Gryshko Flexmonster July 25, 2018

Hello, Bryan,
Thank you for your interest in Flexmonster!
Please check this answer on our forum: Here you can find our recommendations for loading the data using an AJAX call.
Please let me know if it helps.

Bryan July 25, 2018

Thanks for answering.
It worked like a charm  for loading the data using an AJAX call.

Please login or Register to Submit Answer