gwt-material-table icon indicating copy to clipboard operation
gwt-material-table copied to clipboard

Unable to add and delete rows

Open RomanErshov1 opened this issue 7 years ago • 3 comments

In my program, I want to provide the ability to dynamically add and remove rows. Data is taken from database by GWT RPC. In AsyncCalback I use the code: ` @Override public void onSuccess(List<SatConfigView> result) { table.clearRowsAndCategories(true);

            table.setRowData(0, result);
            table.setRedraw(true);
            table.refreshView();
        }`

where result is the data from server. But nothing is happen - additional rows appear after reloading the page. Could you say the solution?

Best regards!

RomanErshov1 avatar Oct 03 '17 20:10 RomanErshov1

try to clear the table first and set the visible range

table.clearRows(true);
table.setVisibleRange(0, result.size());

simerlec avatar Nov 06 '17 08:11 simerlec

I'm also trying to add a row to a specific index position in gwt-material-table. Is it always necassary to clear and reset all data of the table? These are always a lot of DOM operations... and it's also difficult to insert a row at a specific position when table is sorted, because everything is redrawn with that sorting when adding a row. Is there another solution for tis?

davidmoers avatar Feb 19 '18 10:02 davidmoers

@davidmoers if you are trying to update a specific row try doing it through the model object rather than setRowData using updateRow. However if you are trying to "insert" a row perhaps this is something that needs to be added. Inserting data requires a number of reindexing operations so rebuilding is often the way to go, but it would be possible to minimize this too.

BenDol avatar Feb 19 '18 11:02 BenDol