Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

304
Visualizações
How to bind JSON data from ajax call to DataSource of pivot table webdatarocks

Here the data is not binding in the following code:

        var pivot = new WebDataRocks({
            container: "#wdr-component",
            toolbar: true,
            height: 395,
            report: {
                dataSource: {
                    dataSourceType: "json",
                    data: getData()
                },
                "slice": {
                    "rows": [
                        {
                            "uniqueName": "RLI_RAV_GRP_DES"
                        }
                    ],
                    "columns": [
                        {
                            "uniqueName": "LEVEL1"
                        },
                        {
                            "uniqueName": "LEVEL2"
                        }
                    ],
                    "measures": [
                        {
                            "uniqueName": "Q1",
                            "aggregation": "sum"
                        },
                        {
                            "uniqueName": "Q2",
                            "aggregation": "sum"
                        },
                        {
                            "uniqueName": "Q3",
                            "aggregation": "sum"
                        },
                        {
                            "uniqueName": "Q4",
                            "aggregation": "sum"
                        }
                    ]
                },
                options:
                {
                    grid: {
                        title: "Sales Report"
                    }
                }
            }
        });
    

    function getData() {
        $.ajax({
            type: "GET",
            url: "NACGSample.aspx/GetPivotReportList",
            contentType: "application/json; charset=utf-8",
            dataType: 'json',
            success: function (msg) {
                return JSON.parse(msg.d);
                //return msg.d; 
            },
            error: function (msg) { return alert(msg); }
        });
    }
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The issue is that you can not return a value from an asynchronous call (AJAX request). The solution is to call a function inside your success: callback that passes the data when it is available.

Please check the following CodePen: https://codepen.io/webdatarocks/pen/eYErgGL?editors=1010

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda