use of org.eclipse.scout.rt.client.ui.basic.table.ITableRowFilter in project scout.rt by eclipse.
the class JsonTableTest method testAddRowFilterAfterUpdates.
@Test
public void testAddRowFilterAfterUpdates() throws Exception {
TableWith3Cols table = new TableWith3Cols();
table.fill(3);
table.initTable();
JsonTable<ITable> jsonTable = m_uiSession.createJsonAdapter(table, null);
// Simulate that the full table is sent to the UI
jsonTable.toJson();
JsonTestUtility.processBufferedEvents(m_uiSession);
JsonTestUtility.endRequest(m_uiSession);
// Now filter the first row
ITableRow row = table.getRow(0);
String row0Id = jsonTable.getOrCreateRowId(row);
assertNotNull(row0Id);
assertNotNull(jsonTable.getTableRow(row0Id));
table.addRowFilter(new ITableRowFilter() {
@Override
public boolean accept(ITableRow r) {
// hide first row
return r.getRowIndex() > 0;
}
});
// Update the (now hidden) row --> should not trigger an update event, because the row does not exist in the UI
row.getCellForUpdate(0).setValue("Updated text");
// We expect the first row to be removed from the table, and no update event!
assertEquals(3, table.getRowCount());
assertEquals(2, table.getFilteredRowCount());
assertEquals(0, m_uiSession.currentJsonResponse().getEventList().size());
// contains row_filter_changed and rows_updated
assertEquals(2, jsonTable.eventBuffer().size());
// Filtering is implemented by Only one deletion event should be emitted (no update event!)
// Conversion of rowFilterChanged event happens here -> // TYPE_ROW_FILTER_CHANGED + TYPE_ROWS_UPDATED = TYPE_ROWS_DELETED
JsonTestUtility.processBufferedEvents(m_uiSession);
assertEquals(1, m_uiSession.currentJsonResponse().getEventList().size());
assertEquals("rowsDeleted", m_uiSession.currentJsonResponse().getEventList().get(0).getType());
}
Aggregations