Tabulator: Disable cell editor in a row if specific field is empty

Created on 28 Sep 2017  路  3Comments  路  Source: olifolkerd/tabulator

I am able to prevent cell click events on cells in a row where a specific column/field (e.g."name") is empty/undefined using e.g.

cellClick: function(e, cell) {
          var row = cell.getRow()
          var name = row.getCell("name").getValue();
          if (name === undefined) {
            return false
          } else {do something else.....}

However, this does not work on cells in columns where I have set editor:true as this seems to override the cellClick function.

Any ideas how I could block editing of cells in rows where the "name" column contains no data but allow editing (using simple text input or a dropdown via editor:trueor editor: mycustomEditorin rows where a name is present in the "name" column?

Question - Ask On Stack Overflow

Most helpful comment

you can use the editable callback in the column definition to determine weather a cell is editable or not:

var editCheck = function(cell){
    //cell - the cell component for the editable cell

    //get row data
    var data = cell.getRow().getData();

    return !!(data.name) // only allow the name cell to be edited if the age is over 18
}

//in your column definition for the column
{title:"Name", field:"name", editor:"input", editable:editCheck}}

The callback will be tirggered when the user clicks on the cell so you can check the cells value in there.

All 3 comments

you can use the editable callback in the column definition to determine weather a cell is editable or not:

var editCheck = function(cell){
    //cell - the cell component for the editable cell

    //get row data
    var data = cell.getRow().getData();

    return !!(data.name) // only allow the name cell to be edited if the age is over 18
}

//in your column definition for the column
{title:"Name", field:"name", editor:"input", editable:editCheck}}

The callback will be tirggered when the user clicks on the cell so you can check the cells value in there.

Wow, thanks for your prompt reply and really sorry I missed this in the documentation!

Tabulator is an awesome piece of coding - really appreciate all your efforts.

I want to Disable all rows in tabulator. how can i make it.

Was this page helpful?
0 / 5 - 0 ratings