Prevent Tab from adding new placeholder task


#1

Using this sample:
https://docs.dhtmlx.com/gantt/samples/07_grid/12_inline_edit_key_nav.html

Is it possible to prevent the the placeholder task from saving when I get TAB or Right Key?

Current behavior:

  1. Enter a new name for the placeholder task
  2. Hit TAB
  3. Task is saved and the next task is focused.

Desired behavior:

  1. Enter a new name for the placeholder task
  2. Hit TAB
  3. The Duration column editor is focused

Thank you


#2

Hello lgcu,
There is no built-in feature to do that. You need to change the keyboard mapping:
https://docs.dhtmlx.com/gantt/desktop__inline_editing.html#inlineeditingmodes
The easiest way is to edit the existing keyboard mapping.
First, you copy the current mapping:

var custom_mapping = gantt.ext.inlineEditors.getMapping;

Then you replace the default mapping:

            case c.LEFT:
            case c.RIGHT:
                "date" === l.editorType && (d = !0);
            	t.isVisible() && gantt.getTask(t.getState().id).type == 'placeholder' && (t.setValue());
                break;

and

                if (t.isVisible()) {
                    if (r.shiftKey) t.editPrevCell(!0) 
                    else if (gantt.getTask(t.getState().id).type == 'placeholder') (t.setValue(), t.editNextCell(!0))
                  	else t.editNextCell(!0)

Here is an example of how it might be implemented:
http://snippet.dhtmlx.com/2f7c1a9e2


#3

Thanks Ramil! I appreciate the sample code.