Greg-A
Greg-A

Reputation: 862

Problem with onCellValueChanged and Tab Key in Ag-grid

Ag-grid version : 3.3

I have a table with an editable cell

  {
    field: 'montant',
    headerName: 'montant',
    cellClass: 'text-right',
    filter: 'number',
    editable: true,
    valueGetter: function(params) {
      params.data.montant = parseFloat(params.data.montant);
      if (_.isNaN(params.data.montant)) return $filter('formatNumber')(params.data.montant, vm.devise.type);
      return params.data.montant;
    },
    template:
      '    <span ng-if="mode===\'AMOUNT\'">{{data.montant | formatNumber: devise}} <i class="fa fa-pencil-square"></i></span>\n' +
      '    <span ng-if="mode===\'PERCENT\'">{{data.montant | percent}} <i class="fa fa-pencil-square"></i></span>'
  }

I also use OnCellValueChanged at each change of the editable cell which allows me to calculate the sum of my cells.

function onCellValueChangedFunc(params) {
  if (!_.isUndefined(params)) {
    vm.calc(params.data.montant);
  }
}

when I click on each cell and change the value, the value is displayed and the total amount also changes.

But when I use the tab keyboard key I can change the values but it returns an empty value and the calculation is not performed.

enter image description here

I have to get out of the tab to see the cell changes

Do you have a solution for this problem?

Upvotes: 0

Views: 1179

Answers (1)

lokesh kotha
lokesh kotha

Reputation: 92

You can use focusIn() function of ICellEditorAngularComp provided by Ag Grid to implement this.

Upvotes: 1

Related Questions