Sortable does not work

2 posts, 0 answers
  1. Jorrit
    Jorrit avatar
    2 posts
    Member since:
    May 2016

    Posted 13 Jul Link to this post

    With a remote data source, I can't get sortable working. In the UI the user can choose "Sort Ascending" or "Sort Descending", but the expanded values remain unsorted. Filter and all other features do work. Below the code. What am I doing wrong here? Thanks in advance.

    $(document).ready(function () {
     
        // prefilter posted from main page
        var postedCriteria = {{ json_encode($criteria) }};
     
        // used for pivot/chart integration
        var collapsed = { columns: [], rows: [] };
     
        var dataSource = new kendo.data.PivotDataSource({
            transport: {
                read: {
                    url: '{{ url("rapport/query") }}',
                    type: "get",
                    dataType: "json",
                    data: { criteria: postedCriteria }
                }
            },
            schema: {
                data: "clients",
                cube: {
                    dimensions: {
                        Client_geslacht: { caption: "Geslacht" },
                        Client_redenAfwijzing: { caption: "Reden voor afwijzing" },
                        Client_aanmelderSoort: { caption: "Aanmeldersoort" },
                        Client_landHerkomst: { caption: "Land van herkomst" },
                        Status_status: { caption: "Status" },
                    },
                    measures: {
                        "Aantal clienten": { field: "Client_id", aggregate: CountDistinctAggregate },
                        "Aantal resultaten": { field: "Resultaat_id", aggregate: CountDistinctAggregate },
                        "Totaalbedrag leefgeld": { field: "Leefgeld_bedragLeefgeld", format: "{0:c}", aggregate: "sum" },
                    }
                }
            },
            columns: [{ name: "Client_geslacht", expand: true }],
            rows: [{ name: "Status_status", expand: true }],
            measures: ["Aantal clienten"]
        });
     
        var pivotgrid = $("#pivotgrid").kendoPivotGrid({
            filterable: true,
            sortable: true,
            columnWidth: 120,
            height: 570,
            dataSource: dataSource,
     
            // chart integration:
            dataBound: function () {
                initChart(convertData(this.dataSource, collapsed));
            },
            // chart integration: gather the collapsed members
            collapseMember: function (e) {
                var axis = collapsed[e.axis];
                var path = e.path[0];
     
                if (axis.indexOf(path) === -1) {
                    axis.push(path);
                }
            },
            // chart integration: gather the expanded members
            expandMember: function (e) {
                var axis = collapsed[e.axis];
                var index = axis.indexOf(e.path[0]);
     
                if (index !== -1) {
                    axis.splice(index, 1);
                }
            },
        }).data("kendoPivotGrid");
     
        $("#configurator").kendoPivotConfigurator({
            dataSource: pivotgrid.dataSource,
            filterable: true,
            height: 570
        });
     
        $("#exportToExcel").click(function() {
            pivotgrid.saveAsExcel();
        });
     
    });
     
    function CountDistinctAggregate(value, state, context)
    {
        if (!state.distinctList) {
            state.distinctList = new Array();
        }
        if (value == null || $.inArray(value, state.distinctList) > -1) {
            return (state.accumulator || 0);
        }
        else {
            state.distinctList.push(value);
            return (state.accumulator || 0) + 1;
        }
    }

     

  2. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3706 posts

    Posted 14 Jul Link to this post

    Hi,

    The PivotGrid supports sorting when binding to OLAP is used. Currently, the sorting is not supported when widget is bound to flat data.

    More details on the topic can be found here:

    http://docs.telerik.com/kendo-ui/controls/data-management/pivotgrid/overview#sorting

    Regards,
    Georgi Krustev
    Telerik by Progress
     
    Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
     
  3. Kendo UI is VS 2017 Ready
Back to Top