(newObj)
| 212 | } |
| 213 | |
| 214 | addAtBegin(newObj) { |
| 215 | if (!newObj[this.keyField] || newObj[this.keyField].toString() === '') { |
| 216 | throw new Error(`${this.keyField} can't be empty value.`); |
| 217 | } |
| 218 | const currentDisplayData = this.getCurrentDisplayData(); |
| 219 | currentDisplayData.forEach(function(row) { |
| 220 | if (row[this.keyField].toString() === newObj[this.keyField].toString()) { |
| 221 | throw new Error(`${this.keyField} ${newObj[this.keyField]} already exists`); |
| 222 | } |
| 223 | }, this); |
| 224 | currentDisplayData.unshift(newObj); |
| 225 | if (this.isOnFilter) { |
| 226 | this.data.unshift(newObj); |
| 227 | } |
| 228 | this._refresh(false); |
| 229 | } |
| 230 | |
| 231 | add(newObj) { |
| 232 | const e = this.isValidKey(newObj[this.keyField]); |
no test coverage detected