Datatable row editing end event

Hi there,

I am trying to get an event as soon as the row editing ended but so far I had no luck to accomplish this.

I’ve created a simple table with static data:[…] and an onItemDblClick handler calling this.editRow(id).

So far so good, all the editors are shown. Now I would like to know if the user ended editing the ROW and why (ESC key or anything else clicked). There are a couple of events but what I am missing is basically one event that is fired after all onAfterEditStop or all onBeforeEditStop events were fired. Something like “onRowEditStop”

The problem with onAfterEditStop is that it get’s fired for every editor and the row data (including validation results) is not complete until all editors stopped.
I don’t like to trust on the event or column order to just react on this event on the last column editor.

I tried to use the $obj validation rule but this gets fired for every changed editor value (what btw. I assume is wrong/a bug - $obj should be called only once for the row/record) like the onDataUpdate event too. So again this can’t tell me when the editing ended.

Is there something I am missing? Any way to accomplish this?

My use case is quite simple: I must send one update with all fields for one row editing operation to the server or undo all changes if the user canceled editing.

Many thanks :slight_smile:

Hi,

Right you are, Webix editing events occur only for each opened editor.
You can use onAfterEditStop for the last column: check the column ID and return false for others.

Especially for esc key handling there’s the ignoreUpdate flag of the mentioned event. For any other case, you need to consider some other conditions or define another hotkey.

Here’s an approximate solution: http://webix.com/snippet/fb93971e

In case of the $obj validation: http://webix.com/snippet/c47be798

Thanks Listopad! I came up with a similar workaround but yours is much cleaner. Thanks a lot!

Hello, If not all columns are editable (have editors defined) is there a way to determine how many editors a row has? The example provided is very useful but expects all columns to be editable, checking the field index against the number of columns in the row. What would a suitable approach be to having only some columns editable?
Thank you
-SrvrSde

Hello,

but expects all columns to be editable

The same approach will work if some column hasn’t an editor:

http://webix.com/snippet/770b186a

Hello Listopad,
I’m sorry I think I’m missing something. If the last column of a row is not editable, then surely the CIndex test against the number of columns will never trigger that the row edit is over. In that case it seems (to me) that coboluxx’ original problem (and my own) of having to rely on hard coded column counts would re-emerge. http://webix.com/snippet/fc26f194
I was originally wondering if there was a way to determine the number of editors defined on a row and use that reference rather than the total number of rows. Perhaps it’s a dumb question but I can’t work out how to avoid hard coded column id’s.
-SrvrSide

Yep, there is no default solution for such case. You can use something like next

    onAfterEditStop:function(state, editor, ignore){
      if (ignore){
        this.editCancel();
      	return;
      } else {
        var max = this.config.columns.length;
        var now = this.getColumnIndex(editor.column);
        
        for (var i=now+1; i<max; i++)
          if (this.config.columns[i].editor)
            return false;
      }
      
      var result = this.validate(editor.row);
      webix.message("Row is done");
      
      return false;
    }

It is a bit verbose, but will work for any set of editable columns.

http://webix.com/snippet/00b91a23

Thank you very much maksim