Hi,
We want to set sort field and direction after the grid initialize it self. We are using levelSortDirections but it does not sort. Is there any other field we need to set?
Hello Jeffrey,
The "levelSortDirections" option sorts the row and column headers and not the data itself. There is no public option to sort the column data itself, but this can be achieved with using an internal API.
Here is the code:
function applySorting() {
var pivot = $("#pivotGrid").data("igPivotGrid");
pivot._tableView.levelSortDirections([]);
pivot._tableView.columnSortDirections([{"memberNames":["[Product].[Product].[ProductCategory].&[All Products]&[Accessories]"],"tupleIndex":3,"sortDirection":"ascending"}]);
pivot._tableView.initialize();
pivot.updateGrid();
}
In order to sort column you need to provide the full path to the member name and tupleIndex. One way to get the tuple index is to inspect the table header cell for the "data-tuple" attribute.
I'm attaching sample for your reference.
Disclaimer: As this approach uses an internal variable, it might not work in a future versions.
Best regards,Martin PavlovInfragistics, Inc.