diff --git a/src/main/webapp/resources/js/base/dataset.js b/src/main/webapp/resources/js/base/dataset.js index cf729a2..9d04161 100644 --- a/src/main/webapp/resources/js/base/dataset.js +++ b/src/main/webapp/resources/js/base/dataset.js @@ -543,11 +543,16 @@ class Dataset { } _getDataItems(obj, option) { - obj = obj || {}; + obj = obj || []; + let array = Array.isArray(obj) ? obj : null; + if (!array && this.conf.dataGetter) + array = this.conf.dataGetter(obj) || []; + array = array || []; +/* let array = Array.isArray(obj) ? obj : this.conf.dataGetter(obj) || []; if (!Array.isArray(array)) throw new Error("The data must be an array"); - +*/ let prefix = "ndx-" + new Date().getTime(), _items = array.map(e => new DataItem(e, this._formats)), _byKeys = {}, @@ -684,7 +689,7 @@ class Dataset { * @returns {Dataset} the Dataset */ clear() { - this.setData(null); + this.setData([]); return this; } @@ -1452,7 +1457,7 @@ class Dataset { } class DatasetControl { - constructor(conf) { + constructor(conf = {}) { this.prefix = conf.prefix; this.prefixName = conf.prefixName; // this.doctx = conf.doctx || ""; @@ -1726,6 +1731,10 @@ class DatasetControl { this.reload({prev: selected.length == this.dataset.length}); } + clear() { + this.dataset.clear(); + } + selector(selector) { return this.doq.selector(selector); }