We have updated Flexmonster Software License Agreement, effective as of September 30, 2024. Learn more about what’s changed.

How to set DataSource from Ajax call

Resolved
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: "https://cdn.flexmonster.com/",
        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() {
        $.ajax({
            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

Public
Tanya Gryshko Tanya Gryshko Flexmonster July 25, 2018

Hello, Bryan,
Thank you for your interest in Flexmonster!
Please check this answer on our forum: https://www.flexmonster.com/question/my-browser-is-paused-after-drawing-pivot/#answer-14897. Here you can find our recommendations for loading the data using an AJAX call.
Please let me know if it helps.
Regards,
Tanya

Public
Bryan July 25, 2018

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

Please login or Register to Submit Answer