From 56599e0658d8444466c255a3edd788ee3c155dd5 Mon Sep 17 00:00:00 2001 From: "Ahmad K. Bawaneh" Date: Mon, 15 Jan 2024 00:20:59 +0300 Subject: [PATCH] fix #900 Add the ability to insert/remove records from LocalListDataStore by index --- .../datatable/store/LocalListDataStore.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/domino-ui/src/main/java/org/dominokit/domino/ui/datatable/store/LocalListDataStore.java b/domino-ui/src/main/java/org/dominokit/domino/ui/datatable/store/LocalListDataStore.java index 39129e4fd..94d8a1b75 100644 --- a/domino-ui/src/main/java/org/dominokit/domino/ui/datatable/store/LocalListDataStore.java +++ b/domino-ui/src/main/java/org/dominokit/domino/ui/datatable/store/LocalListDataStore.java @@ -553,6 +553,19 @@ public void addRecord(T record) { setData(newData); } + /** + * Inserts a single record to the data store at the specified index, updating both the original + * and filtered lists. + * + * @param index The insertion index. + * @param record The record to be added. + */ + public void insertRecord(int index, T record) { + original.add(index, record); + List newData = new ArrayList<>(original); + setData(newData); + } + /** * Removes a single record from the data store, updating both the original and filtered lists. * @@ -566,6 +579,16 @@ public void removeRecord(T record) { } } + /** + * Removes a single record from the data store from the specified index, updating both the + * original and filtered lists. + * + * @param index The index of the record to be removed + */ + public void removeRecord(int index) { + removeRecord(original.get(index)); + } + /** * Updates a single record in the data store by replacing it with a new record, updating both the * original and filtered lists.