您可以指定自定义内联编辑器。为此,您需要通过以下方式创建一个新的编辑器对象:
gantt.config.editor_types.custom_editor = {
show: function (id, column, config, placeholder) {
// called when input is displayed, put html markup of the editor into placeholder
// and initialize your editor if needed:
var html = "";
placeholder.innerHTML = html;
},
hide: function () {
// called when input is hidden
// destroy any complex editors or detach event listeners from here
},
set_value: function (value, id, column, node) {
// set input value
},
get_value: function (id, column, node) {
// return input value
},
is_changed: function (value, id, column, node) {
//called before save/close. Return true if new value differs from the original one
//returning true will trigger saving changes, returning false will skip saving
},
is_valid: function (value, id, column, node) {
// validate, changes will be discarded if the method returns false
return true/false;
},
save: function (id, column, node) {
// only for inputs with map_to:auto. complex save behavior goes here
},
focus: function (node) {
}
}
为了实现可重用的编辑器,需要记住一些关键点: