This is a migrated thread and some comments may be shown as answers.

Sortable does not work

1 Answer 147 Views
PivotGrid
This is a migrated thread and some comments may be shown as answers.
Jorrit
Top achievements
Rank 1
Jorrit asked on 13 Jul 2016, 11:09 AM

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;
    }
}

 

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 14 Jul 2016, 08:16 AM
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.
 
Tags
PivotGrid
Asked by
Jorrit
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or