Added support for on-demand loading of items in Select2. Fixes #5038.

This commit is contained in:
Aditya Toshniwal
2020-01-01 11:24:16 +05:30
committed by Akshay Joshi
parent fc5287bd9f
commit 737f8375fb
4 changed files with 70 additions and 2 deletions
@@ -883,6 +883,7 @@ define([
select2_opts = _.extend({
openOnEnter: false,
multiple: false,
onDemandLoad: true,
}, self.defaults.select2,
(col.select2 || {})
),
@@ -943,6 +944,12 @@ define([
select2_opts['placeholder'] = '';
}
if(select2_opts.onDemandLoad) {
select2_opts.dataAdapter = $.fn.select2.amd.require('select2/onDemandDataAdapter');
if(_.isUndefined(select2_opts.ajax)) {
select2_opts.ajax = {};
}
}
// Initialize select2 control.
this.$sel = this.$select.select2(select2_opts);