We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

How sort summary column from grouped column.

Hi, I've a ejGrid with 2 columns: Customer, Total amount.  Customer is grouped and I would like order Total amount by descending, it is possible?

thanks a lot
Oscar Montesinos

5 Replies

SS Seeni Sakthi Kumar Seeni Raj Syncfusion Team July 7, 2016 09:52 AM UTC

Hi Oscar,  

We suspect that you would like to sort the “Total Amount” column along with grouping the “Customer” column.  In the actionBegin event of Grid, push the “Total Amount” column and its sorting direction in the sortedColumns of sortSettings. When “ungrouping” the “Customer” column, “Total Amount” column splice the corresponding object from the sortSettings.sortedColumns. Refer to the following code example. 

<div id="Grid"></div> 
<script type="text/javascript"> 
    $(function () { 
        $("#Grid").ejGrid({ 
            dataSource: window.gridData, 
            allowPaging: true, 
            allowSorting: true, 
            allowFiltering: true, 
            allowGrouping: true, 
            actionBegin: function (args) { 
                if (this.model.groupSettings.groupedColumns.indexOf("CustomerID") != -1) { //for grouping 
                    var cols = this.model.sortSettings.sortedColumns; 
                    if (!ej.DataManager(cols).executeLocal(new ej.Query().where("field", "equal", "Freight")).length) 
                        this.model.sortSettings.sortedColumns.push({ field: "Freight", direction: "descending" }) 
                } 
                else if (args.requestType == "ungrouping" && args.columnName == "CustomerID") { //for ungrouping 
                    var cols = this.model.sortSettings.sortedColumns; 
                    var index = cols.indexOf(ej.DataManager(cols).executeLocal(new ej.Query().where("field", "equal", "Freight"))[0]); 
                    this.model.sortSettings.sortedColumns.splice(index, 1) 
                } 
            }, 
            groupSettings: { groupedColumns: ["CustomerID"] }, 
            columns: [ 
                     { field: "CustomerID", headerText: "Customer" }, 
                     { field: "Freight", headerText: "Total Amount", format: "{0:C}" } 
            ] 
        }); 
    }); 
</script> 

We have prepared a sample that can be referred from the following jsPlayground. 


Refer to the following Help Document. 


Regards, 
Seeni Sakthi Kumar S. 



OM Oscar Montesinos July 15, 2016 12:31 PM UTC

I'm sorry, I've can reply soon, but my order problem is with summary row,  I need order by summary column in summary row like :

Grouping Customer....

Customer 1:  Total Freight: 2000$--> (I need order by this field, actually with sample order is by Customer Grouped and Freight)
...................................................
Customer 2:   Total Freight: 1000$

best regards,
Oscar


SS Seeni Sakthi Kumar Seeni Raj Syncfusion Team July 18, 2016 12:48 PM UTC

Hi Oscar, 

Before proceeding with your requirement, we request you to provide more and detailed information on it. In our previous update, we have provided the solution to sort the other column based on the grouping action of other column which will the sort the Grid based on the records present in the given column. Please provide following information to analyze the issue. 

1)      We have also noticed your quote, “sort summary column from grouped column”, would you like to sort the column based on the result of groupSummary as highlighted in the below code example? 

 

2)      Please explain the exact scenario and explain it with any picture. For instance, if you would like to sort the “Total Amount” column along with the grouping the “Customer” column, Group the “Customer” column (external action), sort the “Total Amount” column (internal action). 

Regards, 
Seeni Sakthi Kumar S. 



OM Oscar Montesinos July 18, 2016 12:59 PM UTC

Thanks a lot, Yes to point 1), only I need to sort the column based on the result of groupSummary,

best regards
Óscar


SS Seeni Sakthi Kumar Seeni Raj Syncfusion Team July 19, 2016 12:27 PM UTC

Hi Oscar, 

We could see that you would like to “Sort the column based on summary value”. As this feature is not available with our product, we have considered your requirement as feature and created a new support incident to track this. Please log on to our support website to check for further updates. 


Regards, 
Seeni Sakthi Kumar S. 


Loader.
Live Chat Icon For mobile
Up arrow icon