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

Need only one active content in data grid list [Detailed Template].

Hi,
I want to display the detailed template data grid with only one content expanded and others in collapsed state.
Please check the below link for reference:



Regards,
Ebenezer Justin


1 Reply

PS Pavithra Subramaniyam Syncfusion Team April 30, 2019 08:36 AM UTC

Hi Ebenezer, 
 
Thanks for contacting Syncfusion Support. 
 
We have validated your query. You can achieve your requirement using expand() and collapseAll() method of the detailRowModule  inside the created event of Grid component. Please find the below code snippet. 
 
Please find the below code example, sample and documentation link for your reference. 
 
[component.ts] 
expand() { 
    this.gridObj.element.addEventListener('click', (e)=>{ 
          if(parentsUntil(e.target as Element, 'e-detailrowexpand')) { 
            this.gridObj.detailRowModule.collapseAll(); 
            let row = parentsUntil(e.target as Element , 'e-row'); 
            let rowIndex = parseInt(row.getAttribute('aria-rowindex')); 
            this.gridObj.detailRowModule.expand(rowIndex); 
          } 
    }); 
  } 
 
 
Sample                       https://stackblitz.com/edit/angular-detailtemplate-144292?file=app.component.ts 
 
                                      https://ej2.syncfusion.com/angular/documentation/api/grid#created  
 
Regards, 
Pavithra S. 


Loader.
Up arrow icon