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.
Unfortunately, activation email could not send to your email. Please try again.

How sort summary column from grouped column.

Thread ID:

Created:

Updated:

Platform:

Replies:

124884 Jul 6,2016 04:55 AM Jul 19,2016 08:27 AM JavaScript 5
loading
Tags: ejGrid
Oscar Montesinos
Asked On July 6, 2016 04:55 AM

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

Seeni Sakthi Kumar Seeni Raj [Syncfusion]
Replied On July 7, 2016 05:52 AM

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. 


Oscar Montesinos
Replied On July 15, 2016 08:31 AM

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

Seeni Sakthi Kumar Seeni Raj [Syncfusion]
Replied On July 18, 2016 08:48 AM

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. 


Oscar Montesinos
Replied On July 18, 2016 08:59 AM

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

best regards
Óscar

Seeni Sakthi Kumar Seeni Raj [Syncfusion]
Replied On July 19, 2016 08:27 AM

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. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;