Hi David,
The sorting has an insane amount of customization available, more than you need (i think). I’d highly recommend going the layers approach for something as simple as your requirement, you can do with completely without code.
If you’re interested in getting deeper into the code side, here is some rough and untested code that you can use as a baseline to do your own. You can see from this why i recommend the layers approach.
function getOrCreateMetricSetBindingOverride(currentView, adapterId, metricSetBindingId) {
var override = currentView.overrides.getMetricSetBindingOverrideById(adapterId, metricSetBindingId);
if (!override) {
override = {
“adapterId”: adapterId,
“metricSetBindingId”: metricSetBindingId,
“requestOverrides”: new dundas.data.RequestOverrides()
};
currentView.overrides.metricSetBindingOverrides.push(override);
}
return override;
}
function getOrCreateMeasureOverrides(override, uniqueName) {
var measureOverrides = override.measureOverrides.filter(function (measureOverrides) {
return measureOverrides.uniqueName == uniqueName;
})[0];
if (measureOverrides == null) {
measureOverrides = new dundas.data.RequestMeasureOverrides({
"uniqueName": uniqueName
});
override.measureOverrides.push(measureOverrides);
}
return measureOverrides;
}
function getOrCreateHierarchyOverrides(override, uniqueName) {
var hierarchyOverrides = override.hierarchyOverrides.filter(function (hierarchyOverrides) {
return hierarchyOverrides.uniqueName == uniqueName;
})[0];
if (hierarchyOverrides == null) {
hierarchyOverrides = new dundas.data.RequestHierarchyOverrides({
"uniqueName": uniqueName
});
override.hierarchyOverrides.push(hierarchyOverrides);
}
return hierarchyOverrides;
}
var currentView = this.parentView.control;
var metricSetBindingOverride = getOrCreateMetricSetBindingOverride(currentView, chart1.id, chart1.metricSetBindings[0]);
var measureOverrides = getOrCreateMeasureOverrides(metricSetBindingOverride, “SalesYTD”);
measureOverrides.directions = [];
// For each hierarchy + level to sort
measureOverrides.directions.push(
new dundas.data.MeasureSortingByHierarchyLevel(
“direction”: dundas.SortDirection.ASCENDING,
“hierarchyUniqueName”: “”,
“hierarchyLevelUniqueName”: “”
)
);