Angular ag-grid cell renderer checkbox not refresh value

TadeasM

I created cell renderer for checkbox input but when I click checkbox it change the value inside but not on the cell.

See plunker example: Plunker

refresh method should be called on change but somehow it is not.

onCellClicked function returns still same value no matter how I click on checkbox.

I tried cellEditor: 'agRichSelect' with two possible values true and false which worked fine but I need checkbox.

Thaks for any ideas!

un.spike

First, for tracking changes of ngModel you need to use (ngModelChange) instead of (onChange).

Second, you shouldn't use params.value for ngModel binding, params - is a part of grid, so just avoid mixing things and keep it separately.

Third, in refresh function inside cellRenderer you shouldn't update params, refresh function used internally for grid.

// Mandatory - Get the cell to refresh. Return true if the refresh succeeded, otherwise return false.
// If you return false, the grid will remove the component from the DOM and create
// a new component in its place with the new values.
refresh(params: any): boolean;

Fourth, if you want to update value inside cellRenderer you should use ICellEditorComp interface instead of ICellRendererComp(ICellRendererAngularComp and ICellEditorAngularComp on Angular case)

Fifth, you forgot to setup checkbox field editable: true in columnDefs

And the last one - you've just created checkbox (out of grid scope) which is looked like a working sample, but it's not.

You need to understand the full edit process if ag-grid, so just check here details about cell rendering, cell editing and much more.

And here you can see how exactly custom checkbox renderer will work :

function booleanCellRenderer(params) {
    var valueCleaned = booleanCleaner(params.value);
    if (valueCleaned === true) {
        return "<span title='true' class='ag-icon ag-icon-tick content-icon'></span>";
    } else if (valueCleaned === false) {
        return "<span title='false' class='ag-icon ag-icon-cross content-icon'></span>";
    } else if (params.value !== null && params.value !== undefined) {
        return params.value.toString();
    } else {
        return null;
    }

}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

WxGo Grid Cell renderer

Get Cell value after cell rendering applied to it ag-grid

Ag-grid in Angular does not refresh when RowData is changed

ag-grid renders on top of cell renderer

How to conditionally enable/disable cell renderer in Ag-Grid?

ag-grid hide checkbox in some rows depend on the cell value

Ag Grid cell renderer not instantiated until scrolled back in view

How to Render an Angular routerLink inside the cell of an ag-Grid?

How to apply custom css class in ag-grid cell in angular?

getting checkbox value from ag-grid column

ag-grid cell renderer that shows data from multiple columns

Ag-grid cell renderer with slider not working

How to display enum value in ag-grid cell field value?

how to delete ag-grid row with a button in cell renderer

How to give a link in cell with other cell value in ag-grid in Angular?

Dynamically changing Cell Renderer of ag-grid using param function in Angular 8

ag Grid change cell color on Cell Value Change

Angular ag-grid : How to render HTML in cell?

AG-Grid cell template value change

How to apply filter to a cell renderer in ag grid

ag-grid checkbox column checked by renderer

Angular Tooltip showing on the wrong Ag-Grid cell

AG-GRID-ANGULAR - How to check/uncheck checkbox in header component if all checkboxes in the cell renderers are checked/unchecked?

Angular ag-Grid: custom cell renderer that turns on edit mode over all editable cells in row

AG Grid: center checkbox alone in cell

How to align the checkbox and text in cell to center in ag grid angular

Updating cell value from callback in ag grid

Angular ag-grid-angular get rid of cell paddings

Ag-Grid : How to get the value of the cell on clicking the cell