Hot Keys in DataTable

Hi,

I have two Data Tables in my form. I have added hotkeys for custom editing like in:

webix.UIManager.addHotKey(“enter”, function(){
$$(‘Table1’).edit( $$(‘Table1’).getSelectedId());
});

webix.UIManager.addHotKey(“enter”, function(){
$$(‘Table2’).edit( $$(‘Table2’).getSelectedId());
});

Works fine if there is only one table per form. But, when you have multiple tables, getting script error “t is undefined”

Thanks

Ashok

Above code contains hardcoded id of the datatable, but you will want to have the effect for the active datatable only, right ?

You can do it like next
http://webix.com/snippet/738474f1
By using third parameter of addHotKey you limit event handler for datatable’s only. And by using view parameter you are applying the logic for currently active datatable only.

Hi,

The tables are in different tab sheets and one table is part of a popup window. So, I cannot use view. Is there a workaround?

Ashok

Actually you can use the above code in your case.
Code in the snippet adds the new hotkey for ALL instances of datatable, already created and those that will be created after that. It doesn’t really matter where they are placed.

Thanks. Actually, I would like to use both “enter” and “F2” for invoking the editor. Can you please tell how this is done?

Ashok

It seem addHotKey can’t be used for F1-F12 keys :frowning:
You can use a bit more complicated code with onKeyPress handler, or just wait for the next Webix update - where you will be able to use the same code as for Enter key to handle functional keys.

http://webix.com/snippet/e155daee

Thank you

Hello, it seems like the addHotKey still doesn’t work for F1-F12 keys?