Trace: • Record iteration
It's possible to iterate all records of a databook with different techniques. It's a performance decission what's best. Just reading is fastest.
You decide if you iterate for reading or for changing records. An iteration
Iterate with optional record change (Solution 1)
int masterRow = mdbMaster.getSelectedRow(); int detailRow = mdbDetail.getSelectedRow(); boolean resetSelection = false; try { for (int i = 0; i < mdbMaster.getRowCount(); i++) { for (int j = 0; j < mdbDetail.getDataPage(mdbMaster.getDataRow(i)).getRowCount(); j++) { if (changeData) { mdbMaster.setSelectedRow(i); mdbDetail.setSelectedRow(j); resetSelection = true; } } } } finally { if (resetSelection) { mdbMaster.setSelectedRow(masterRow); mdbDetail.setSelectedRow(detailRow); } }
Iterate with optional record change (Solution 2)
int masterRow = mdbMaster.getSelectedRow(); int detailRow = mdbDetail.getSelectedRow(); boolean resetSelection = false; try { for (IDataRow mRow : mdbMaster) { for (IDataRow dRow : mdbDetail.getDataPage(mRow)) { if (changeData) { mdbMaster.setSelectedRow(mRow.getRowIndex()); mdbDetail.setSelectedRow(dRow.getRowIndex()); resetSelection = true; } } } } finally { if (resetSelection) { mdbMaster.setSelectedRow(masterRow); mdbDetail.setSelectedRow(detailRow); } }
Iterate with record change
int masterRow = mdbMaster.getSelectedRow(); int detailRow = mdbDetail.getSelectedRow(); try { for (int i = 0; i < mdbMaster.getRowCount(); i++) { mdbMaster.setSelectedRow(i); for (int j = 0; j < mdbDetail.getRowCount(j); j++) { mdbDetail.setSelectedRow(j); } } } finally { mdbMaster.setSelectedRow(masterRow); mdbDetail.setSelectedRow(detailRow); }