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