Hi,
I am writing a custom editor for datatable using Jquery Select2 plugin for multiselect.
It works fine with single selection. However when I select multiple options, then nothing is saved and the cell becomes blank.
The “getValue()” functions returns the multiple selected options array but nothing is set to the cell.
Please let me know what I am missing in the custom editor?
webix.editors.select2Editor = {
focus : function() {
this.getInputNode().focus();
},
getValue : function() {
if( $(this.getInputNode())!= undefined && $(this.getInputNode()).val() != null){
return $(this.getInputNode()).val();
}
return this.getInputNode().value || "";
},
setValue : function(t) {
$(this.getInputNode()).val($(".select2-editor").val());
},
getInputNode : function() {
return this.node.firstChild;
},
render : function() {
//create a simple multi-select box using config options.
var options = this.config.options;
var keys = Object.keys(options);
var select_box = "<select class='select2-editor' multiple='multiple' view_id='selectView'>";
for(var i=0;i<keys.length;i++){
select_box += "<option value='"+keys[i]+"'>"+options[keys[i]]+"</option>";
}
select_box +="</select>";
return webix.html.create("div", {
"class" : "webix_dt_editor"
}, select_box);
},
afterRender : function() {
$('.select2-editor').select2(); //make it select2 editor
}
};