drillThrough: get the list of rows (context)

Hi, 

 When the user does click on cell I have to obtain the names of rows. 

Using the method drillThrough I have args.rowHeaders but it's not the same of list of rows (it's a label). 

 Example: 

 let dataSourceSettings = { enableSorting: true, columns: [{ name: 'Year' }, { name: 'Quarter' }], valueSortSettings: { headerDelimiter: ' - ' }, values: [{ name: 'Sold', caption: 'Units Sold' }, { name: 'Amount', caption: 'Sold Amount' }], dataSource: getPivotData(), rows: [{ name: 'Country' }, { name: 'Products' }], formatSettings: [{ name: 'Amount', format: 'C0' }], expandAll: false, filters: [] };

 - The user does click on the cell Germany -> Montain Bikes the result would be: ['Country','Products']. 

 - The user does click on the cell Germany the result would be: ['Country'].

 - If the user rearrange the rows to Products -> Country and the user does click on the cell Mountain Bikes => Germany then :['Products','Country'].

 Is there any way to do this ?. 

 Thanks in advance !.

 Jorge


3 Replies

SP Sastha Prathap Selvamoorthy Syncfusion Team July 26, 2021 07:25 AM UTC

Hi Jorge, 

Kindly refer the following code example to get the row information of the clicked cell in the drillThrough event. 

Code Example: 
export class DrillThroughComponent extends SampleBase { 
  render() { 
    return ( 
      <div className="control-pane"> 
        <div className="control-section" style={overflow: 'initial' }}> 
          <PivotViewComponent 
            id="PivotView" ref={pivotview => {pivotObj = pivotview;}} dataSourceSettings={dataSourceSettings} 
            showTooltip={false} width={'100%'} height={'300'} showFieldList={true} 
            allowDrillThrough={true} gridSettings={columnWidth: 140 }} 
            drillThrough={this.drillThrough.bind(this)}> 
            <Inject services={[FieldListDrillThrough]} /> 
          </PivotViewComponent> 
        </div> 
      </div> 
    ); 
  } 
  drillThrough(args) { 
    let rows = []; 
    let headers = args.rowHeaders.split(dataSourceSettings.valueSortSettings.headerDelimiter); 
    for(let header of headers) { 
        for(let field of dataSourceSettings.rows){ 
            if (pivotObj.engineModule.fieldList[field.name] && pivotObj.engineModule.fieldList[field.name].members[header]) { 
                rows.push(field.name); /// here you can get the selected rows. 
                break; 
            } 
        } 
    } 
  } 
} 


Meanwhile, we have prepared a sample for your reference. Please find it from below link. 

Please let us know if you have any concerns. 

Sastha Prathap S. 



JV JORGE V July 28, 2021 06:09 PM UTC

Hi,

It works, I can retrieve the list of fields rows of the clicked cell.

Thank you !.

Jorge



MM Manikandan Murugesan Syncfusion Team July 29, 2021 07:05 AM UTC

Hi Jorge,  
   
Please let us know if you have any other queries. We are always happy to assist you.  
   
Regards,  
Manikandan 


Loader.
Up arrow icon