Sorting in Wijmo Pivot Grid

Posted by: chinmay.patil on 10 October 2017, 4:06 pm EST

    • Post Options:
    • Link

    Posted 10 October 2017, 4:06 pm EST

    Hi,

    Currently im evaluating the Pivot Grid to integrate it with our application. However i couldn’t find a way to achieve the following:

    My requirement is to display the data in the same order i pass to the Pivot Engine. However what happens is that, when the grid loads, the data gets sorted in ascending order with respect to the leftmost rowfield. I want to disable this sort behaviour.

    In short I want the behaviour of the grid to be : Display the data just the way it recieves into its itemsource.

  • Posted 10 October 2017, 4:28 pm EST

    https://www.grapecity.com/en/forums/wijmo/client-side-sorting-overri_2#wijmoarchivehi-shihalvas-p

    Same requirement, except im not talking about the column header click sort event, I’m talking about the sorting that takes place while grid is being loaded. I’m sorting my data server side and the response goes into the pivotEngines itemsource, i don’t want any changes in its order while the grid loads, data should is displayed in the same order as the response.(not using OData service, so cannot use ODataCollectionView)

    Regards,

    Chinmay

  • Posted 11 October 2017, 3:24 am EST

    Hi Chinmay,

    You can use sortComparer method for applying custom sorting in PivotGrid. For this, you need to define the sortComparer method for the field, you would like to show data same.

    For reference, please refer to the attached sample for the same.

    ~Manish Kr Gupta

    Olap_Sorting_SortComparer.zip

  • Posted 11 October 2017, 4:06 am EST

    Hi Manish,

    Thanks for the reply.

    However there’s a problem implementing the solution you suggested, i’ll have to implement the sortComparer method on every field, and the fields in our case are dynamic, so if the number of fields is many, it might be a performance hit. Is there no other way that the pivotGrid just displays the data i provide, because i’m sorting the data in backend already, so i want to avoid any changes in the data i provide, to the itemsource of the pivotEngine.

  • Posted 12 October 2017, 4:40 am EST

    Hi Chimay,

    The behavior is by design since PivotEngine process data and display in PivotGrid/PivotChart. However, we have forwarded this issue to the concerned team for further investigation with tracking id 291052.

    We will let you know as we get an update on this.

    ~Manish

  • Posted 16 October 2017, 12:51 am EST

    Hi Manish,

    Is there any update on the issue?

    Regards,

    Chinmay

  • Posted 16 October 2017, 2:26 am EST

    Hi,

    Our Dev Team is actively working on the issue and currenltly I am unable to provide an ETA for the issue. I will update you regarding the same once we have further updates.

    Thanks,

    Abhishek

  • Posted 30 October 2017, 7:02 am EST

    Hi,

    Can you please provide an update for this?

  • Posted 31 October 2017, 12:25 am EST

    Hi Chinmay,

    This issue is still with the team. We will let you know as we get any update.

    ~Manish

  • Posted 20 November 2017, 11:09 am EST

    Hello all

    Sorry it took me a while to get to this.

    The answer above is correct. The easy way to accomplish custom sorting, including the order of occurrence in the source data, is by using a custom sortComparer function.

    The fact that fields are generated automatically should not be an issue. For example, this code applies a custom sort order to all fields which causes them to be sorted based on their position in the original data:

            // sort fields by order of occurrence in the source data
            ng.fields.forEach(function (field) {
                field.sortComparer = function (val1, val2) {
                    var index1 = findIndex(data, field.binding, val1),
                        index2 = findIndex(data, field.binding, val2);
                    return index1 - index2;
                }
            })
            function findIndex(arr, fld, val) {
                for (var i = 0; i < arr.length; i++) {
                    if (arr[i][fld] == val) return i;
                }
                return -1;
            }
    
    

    I hope this helps.

  • Posted 28 November 2017, 7:10 am EST

    Hi bernardo-castilho,

    Thanks, that solves the problem.

    There is one more thing i wanted to ask, is it possible to sort the grid on the basis of subtotals?

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels