Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
830
Default Sorting in Pivot Grid
posted

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?

  • 23953
    Offline posted

    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 Pavlov
    Infragistics, Inc.

    igPivotGrid_sorting.zip