Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to disable editing for only some rows in ag grid

i want to enable only some rows in my ag-grid(exemple :2/5) based on a condition .

editable:false can't help because it is applied on the whole list unless if there is a method I do not know

any help please

like image 997
L.E Avatar asked May 10 '18 13:05

L.E


People also ask

How do I make rows disabled on ag-Grid?

There is no option in the library to make a single row disabled(both visually and keyboard event based), the only way we could make a single row disabled is by using a customCellRenderer for both header and subsequent cell checkboxes, this allows full control over the checkbox.

How do I turn off edit on ag-Grid?

If you want the grid to stop editing when focus leaves the cell or the grid, set the grid property stopEditingWhenCellsLoseFocus = true .

How do I deselect all selected rows in ag-Grid?

To programatically deselect a single row, use rowNode. setSelected(false) . rowNode. setSelected(isSelected, clearSelection) can be used to select rows as well, and will deselect all rows other than the subject rowNode if clearSelection is true .

How do I make a row editable on ag-Grid?

To enable full row editing, set the grid option editType = 'fullRow' . If using custom cell editors, the cell editors will work in the exact same way with the following additions: focusIn : If your cell editor has a focusIn() method, it will get called when the user tabs into the cell.


1 Answers

You can just bind function to editable property in columnDef, which will be executed on each try of edit

editable: this.checkEditFunction.bind(this)
...
checkEditFunction(params){
    //params.node - for row identity
    //params.column - for column identity
    return !params.node.isRowPinned() // - just as sample
}

.bind(this) - just for accessibility of external functions

like image 80
un.spike Avatar answered Oct 19 '22 22:10

un.spike