MCPcopy Create free account
hub / github.com/AllenFang/react-bootstrap-table / addAtBegin

Method addAtBegin

src/store/TableDataStore.js:214–229  ·  view source on GitHub ↗
(newObj)

Source from the content-addressed store, hash-verified

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]);

Callers 1

handleAddRowAtBeginFunction · 0.80

Calls 2

getCurrentDisplayDataMethod · 0.95
_refreshMethod · 0.95

Tested by

no test coverage detected