javascriptag-gridag-grid-angular

(Ag-Grid) While editing, how to get value changed immediately, not after cell loses focus?


In ag-grid, while entering some values in table, I need to receive updated values on input or change event.

But onCellValueChanged is triggered only when cell loses focus, and I cannot figure out what is the way to get values immediately. The only restriction I have - I can't add custom cellEditor, it needs to be grid default.

Can someone, please, advise how to reach such behavior?


Solution

  • You can get the current value of the cell whilst editing by leveraging the Grid Event onCellKeyDown:

    https://www.ag-grid.com/javascript-grid/keyboard-navigation/#keyboard-events

    var gridOptions = {
        onCellKeyDown: params => {
            console.log('current value', params.event.target.value)
        },
    }
    

    Please see this sample which showcases this: https://plnkr.co/edit/GbMglD1fxTTeSZFj