Getting raw data of selected cells

Hi support,

i am using the  <ejs-pivotview  with

(drillThrough)='drilledData($event)'> with following selection settings:

      this.pivotGridObj.gridSettings.allowSelection = true;
      this.pivotGridObj.gridSettings.selectionSettings =
        { mode: 'Cell', cellSelectionMode: 'Flow', type: 'Multiple' }


How can I retrieve the raw data behind the selected cells from code similar to what is shown in the drillThrough event for the double clicked cell.

  drilledData(args) {
     console.log(args.rawData);
  }

so my pseudocode :

    foreach cell in this.pivotGridObj.selectedCells  {
         process( cell.getRawData);
  }

without showing the dialog box as in drillTrough

Thanks
Rainer
     
 

5 Replies

SN Sivamathi Natarajan Syncfusion Team February 14, 2020 09:19 AM UTC

Hi Rainer, 
 
You can retrieve the raw data for selected cells using following code example. 
 
Code Example: 
 allowDrillThrough: true, 
 
  cellSelected: function (args) { 
    var selectedCells = args.selectedCellsInfo; 
    var rawData = []; 
    if (selectedCells && selectedCells.length > 0) { 
      for (var i = 0; i < selectedCells.length; i++) { 
        var colIndex = selectedCells[i].currentCell.colIndex; 
        var rowIndex = selectedCells[i].currentCell.rowIndex; 
        var pivotValue = this.pivotValues[rowIndex][colIndex]; 
        if (pivotValue.rowHeaders !== undefined && pivotValue.columnHeaders !== undefined && (pivotValue.value)) { 
          if (this.dataType != 'olap') { 
            var indexArray = Object.keys(pivotValue.indexObject); 
            for (var _c = 0, indexArray_2 = indexArray; _c < indexArray_2.length; _c++) { 
              var index = indexArray_2[_c]; 
              // you can fetch the rawData here 
              rawData.push(this.engineModule.data[Number(index)]); 
            } 
          } 
        } 
      } 
    } 
  }, 
 
 
Meanwhile, we have prepared a sample for your reference. Kindly check the below sample link for your reference. 
 
 
We hope that the above sample meets your requirement. 
 
Regards, 
Sivamathi. 



RA Rainer February 14, 2020 10:00 AM UTC

Hi Sivamathi,

thank you for your fast reply. First I checked your example on my machine, which is working fine, exactly what i need.

The I inserted your code into my solution and did some debugging after realizing that there is an issue.

The problem is, that pivotValue.indexObject is empty .

Here the console output of pivotValue:




Here my typescript source code
 /* tslint:disable */

  onCellSelected(args: PivotCellSelectedEventArgs): void {
    var selectedCells = args.selectedCellsInfo;
    var rawData = [];
    if (selectedCells && selectedCells.length > 0) {
      console.log(selectedCells.length);
      for (var i = 0; i < selectedCells.length; i++) {
        var colIndex = selectedCells[i].currentCell.colIndex;
        var rowIndex = selectedCells[i].currentCell.rowIndex;
        var pivotValue = this.pivotGridObj.pivotValues[rowIndex][colIndex] as IAxisSet;
        console.log(colIndex);
        console.log(rowIndex);
        console.log(pivotValue);
        if (pivotValue.rowHeaders !== undefined && pivotValue.columnHeaders !== undefined && (pivotValue.value)) {
          console.log(this.pivotGridObj.dataType);
          if (this.pivotGridObj.dataType != 'olap') {
            console.log(pivotValue.indexObject);   //shows pivot
            var indexArray = Object.keys(pivotValue.indexObject);
            console.log(indexArray); // shows {}
            for (var _c = 0, indexArray_2 = indexArray; _c < indexArray_2.length; _c++) {
              var index = indexArray_2[_c];
              // you can fetch the rawData here 
              rawData.push(this.pivotGridObj.engineModule.data[Number(index)]);
            }
          }
        }
      }
    }
    console.log(rawData);
}

Any idea what is going wrong.
best regards
Rainer


SN Sivamathi Natarajan Syncfusion Team February 14, 2020 10:29 AM UTC

Hi Rainer, 

Thanks for the response.  To get IndexObject in pivot values, the API allowDrillThrough should be true. So, could you please check and enable the property? 

Please let us know if you have concern. 

Regards, 
Sivamathi. 



RA Rainer February 14, 2020 10:32 AM UTC

Hi Sivamathi,

thank you again, that fixed it.
Great support.
Have a nice day.
Rainer



SN Sivamathi Natarajan Syncfusion Team February 14, 2020 10:39 AM UTC

Hi Rainer, 
 
We are happy to assist you. Please get in touch with us if you would require any further assistance.  
 
Regards, 
Sivamathi. 


Loader.
Up arrow icon