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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How can I collapse grouped columns based on a row status

Thread ID:

Created:

Updated:

Platform:

Replies:

146548 Aug 7,2019 08:12 PM UTC Aug 13,2019 06:14 AM UTC ASP.NET Core - EJ 2 3
loading
Tags: DataGrid
pk
Asked On August 7, 2019 08:12 PM UTC

hi,

I want to collapse all the groups that only group one row (and apply another row field condition..) and let the other groups be expanded.

I think the this.groupModule.expandCollapseRows(); on the dataBound event is related, right?

thanks.

Thavasianand Sankaranarayanan [Syncfusion]
Replied On August 8, 2019 09:42 AM UTC

Hi Pablo, 

Greetings from Syncfusion support. 

Yes, we can achieve this requirement using the gridObj.groupMoudle. expandCollapseRows() method in Grid. 

In the below code example, we have collapse some groups based on group key values (“Berlin, Madrid”) in an external button click event. 

[Index.cshtml] 
 
        <ejs-button id="collapseGroup" content="Collapse_Grouped_Rows"></ejs-button> 
 
        <ejs-grid id="Grid" dataSource="ViewBag.datasource" allowGrouping="true"> 
            <e-grid-groupsettings columns="@(new string[] { "ShipCity" })" showGroupedColumn="true"></e-grid-groupsettings> 
            <e-grid-columns> 
 
 
                   ... 
 
            </e-grid-columns> 
        </ejs-grid> 
    </div> 
</div> 
 
<script> 
 
    document.getElementById('collapseGroup').addEventListener('click', function (args) { 
        var obj = document.getElementById('Grid').ej2_instances[0]; 
        var collapsableKeyValue = ["Berlin", "Madrid"]; 
 
        for (var i = 0; i < collapsableKeyValue.length; i++ ) { 
 
            var collapseElement = obj.getContentTable().querySelectorAll("td[ej-mappingvalue= '" + collapsableKeyValue[i] + "']")[0]; 
 
            obj.groupModule.expandCollapseRows(collapseElement); 
 
        } 
    }); 
    
</script> 




We have prepared a sample and it can be downloadable from the below location. 


Regards, 
Thavasianand S. 


pk
Replied On August 12, 2019 06:14 PM UTC

thanks

Balaji Sekar [Syncfusion]
Replied On August 13, 2019 06:14 AM UTC

Hi Pablo, 
 
Thanks for your update,  
 
We glad to hear that your problem has been resolved. 
 
Please get back to us if you need further assistance. 
 
Regards, 
Balaji Sekar. 


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon

Live Chat Icon For mobile
Live Chat Icon