onAfterEditStop isn't fired when another cell is selected

I have datatable with editable column where users can enter only numbers from 1 to 100. To ensure this i have function attached to datatable on onAfterEditStop event and it works fine if user enters value in cell and press enter. But if user enters value and then clicks another cell - it won’t work, as if event not fired. How can I catch this clicking? Which event should I additionally catch?

function body:

        onAfterEditStop: function(state) {
          if(parseInt(state.value)>=100 || parseInt(state.value)<=0) {
            this.getItem(this.getSelectedId()).part="";
            this.refresh();
           }
          }

IMO for such purpose rules attribute would be more suitable:

{
   view: "datatable",
   rules: {
      part: function(value, row) {
         if(parseInt(value)>=100 || parseInt(value)<=0) {
            row.part="";
           }
           return true;
      }
   },
   columns: [...]
}

Wow! Works like a charm, thank you :slight_smile:

> But if user enters value and then clicks another cell - it won’t work

@steelunicorn can you please provide a sample that shows the issue or the exact use-case to repeat it?
By default, such approach works

http://webix.com/snippet/8aa37f3b

@Listopad sure I can. Here it is: http://webix.com/snippet/e6b36dcc just enter values over 100 or below 0 and click to any cell

@steelunicorn once you click another cell, getSelectedId will return its ID (if selection is enabled). As shown in the above sample, withonAfterEditStop solution will look like

if ( /*...*/ ){
    this.blockEvent();
    this.updateItem(editor.row, {[editor.column]:""});
    this.unblockEvent();
}; 

as state and editor objects provide all necessary information for such changes.

However, the solution from @intregal is uncommon but will work great as well.