Loj Loj - 1 month ago 17
Javascript Question

Custom pasting into empty datatable

When I'm trying to paste into the empty area within the webix datatable, nothing happens and

onPaste
event doesn't occur.

Basically, I want to add a new item through onPaste even when existing data items aren't selected. But whether it's possible?

Something like the 'insert' operation in a list, but in my use-case the datatable can be empty after init (in the following sample I've added an item to make clipboard work). Here it is:

http://webix.com/snippet/9ae6635b

webix.ui({
id:'grid',
view:'datatable',
select:true,
clipboard:'custom',
editable:true,
columns:[
{ id:'id' },
{ id:'name', fillspace:true, editor:"text" },
{ id:'details' }
],
data: [
{ }
],
on:{
onPaste: function(text){
this.add({ id:webix.uid(), name:text })
}
}
});


Any suggestions are appreciated.

Loj Loj
Answer

I found that 'clipbuffer' has focus only when datatable has the selection. Most probably it is required for data editing, detecting position or whatever. Anyway, the 'clipbuffer' can be focused manually:

var clipEvent = webix.event($$("grid").getNode(), "click", function(){
      webix.clipbuffer.focus();
});

Sample: http://webix.com/snippet/aa441e70