Grid aggregate and columns edit => final column modification.

Hi, 

Starting from "Automatically update the column based on another column edited value in Batch mode" topic from Grid documentation, i want to do something that include also aggregate functionality.

image 1.PNG

i put the code into an archive file. 


Aurelian, software developer @General Electric.


Attachment: fcrdsharesgrid.component_bca0329b.rar

2 Replies

JC Joseph Christ Nithin Issack Syncfusion Team October 29, 2021 12:55 PM UTC

Hi Aurelian, 

   Greetings from Syncfusion support. 

   Currently we are validating the reported issue. We will provide further details on 2nd November , 2021. We appreciate your patience until then. 

Regards, 
Joseph I. 



JC Joseph Christ Nithin Issack Syncfusion Team November 2, 2021 03:49 PM UTC

Hi Aurelian, 

  Thanks for your patience. 

  Based on your query, you are trying to automatically update the value of a share column based on the values in two of the columns (Consumption TSO, Generation TSO). On inspecting the provided code example we have found that you are using `updateCell` method to update the value of the `share` column. But initially you have defined this column as a non-editable column. By default `updateCell` method can change the values of the specified cell only if the column is defined editable. 

  Hence, we suggest you to use the `setCellValue` method of the EJ2 grid to update the value of the `share` column. 

  Please refer the code example below. 


 
    //Consumption 
    this.consumptionParams = { 
      create: () => { 
        this.consumptionElem = document.createElement('input'); 
        return this.consumptionElem; 
      }, 
      read: () => { 
        return this.consumptionObj.value; 
      }, 
      destroy: () => { 
        this.consumptionObj.destroy(); 
      }, 
      write: (args) => { 
        var rowData = args.rowData; 
        var rowIndex = this.grid.getRowInfo(args.row).rowIndex; 
        this.consumptionObj = new NumericTextBox({ 
          value: args.rowData[args.column.field], 
          change: function (args) { 
            let consumtionSum = (this.grid.aggregateModule as any) 
              .footerRenderer.aggregates.aggregates['ConsumptionTSO - sum']; 
            let generationSum = (this.grid.aggregateModule as any) 
              .footerRenderer.aggregates.aggregates['GenerationTSO - sum']; 
            var share = this.shareCalculation( 
              args.value, 
              rowData['ConsumptionTSO'], 
              consumtionSum, 
              generationSum 
            ); 
            //var share = ((rowData['ConsumptionTSO'] + args.value) / (consumtionSum + generationSum)) * 100; 
            //let share = args.value * rowData['ConsumptionTSO']; 
            console.log('consumtionSum : ', consumtionSum); 
            console.log('generationSum : ', generationSum); 
            console.log('share : ', share); 
 
            this.grid.setCellValue(rowData['Area'], 'Share', share); 
          }.bind(this), 
        }); 
        this.consumptionObj.appendTo(this.consumptionElem); 
      }, 






Please find the attached sample and revert for more queries. 

Regards, 
Joseph I. 


Loader.
Up arrow icon