SmartClient Version: SNAPSHOT_v11.1d_2017-01-31/PowerEdition Deployment (built 2017-01-31)
I want to suppress the auto removal of ONE particular record in a ListGrid, when calling saveAllEdits()
I tried to add a addRemoveRecordClickHandler but it seems to suppress the remove of all records.
final ListGrid techGrid = new ListGrid() ;
techGrid.setDataSource("ISO_UIProjectTechnology");
techGrid.setShowFilterEditor(true);
techGrid.setAutoFitFieldWidths(true);
techGrid.setAutoFitData(Autofit.BOTH);
techGrid.setCanEdit(true);
techGrid.setCanRemoveRecords(true);
techGrid.setAutoFetchData(true);
techGrid.setDeferRemoval(true);
techGrid.setAutoFitMaxRecords(22);
With just the above code, clicking the remove icon marks the record for removal and removes the record when the icon that controls 'saveAllEdits()' is clicked. All is well except I want to suppress the behavior for one record value.
So I added this code:
techGrid.addRemoveRecordClickHandler(new RemoveRecordClickHandler() {
@Override
public void onRemoveRecordClick(RemoveRecordClickEvent event) {
int row = event.getRowNum();
Record recRm = techGrid.getRecord(row);
String rule = recRm.getAttributeAsString("TechDescription");
if ( "generic".equalsIgnoreCase(rule)){
SC.warn("No one may remove the <b><i>generic</i></b> Tech Rule Type");
techGrid.unmarkRecordRemoved(row);
}
techGrid.markRecordRemoved(row);
return;
}
} );
Now clicking the remove icon on the row containing the value 'generic' gets a popup warning not allowing the remove. But clicking any other record a) does not mark the record for removal and b) does not cause the record to be removed when saveAllEdits() is called.
Do I have to define a techGrid.removeData() function instead of the simple use of markRecordRemoved()? How can I retain the functionality of marking the records for delete and only executing the delete when saveAllEdits() is called?
Thanks
I want to suppress the auto removal of ONE particular record in a ListGrid, when calling saveAllEdits()
I tried to add a addRemoveRecordClickHandler but it seems to suppress the remove of all records.
final ListGrid techGrid = new ListGrid() ;
techGrid.setDataSource("ISO_UIProjectTechnology");
techGrid.setShowFilterEditor(true);
techGrid.setAutoFitFieldWidths(true);
techGrid.setAutoFitData(Autofit.BOTH);
techGrid.setCanEdit(true);
techGrid.setCanRemoveRecords(true);
techGrid.setAutoFetchData(true);
techGrid.setDeferRemoval(true);
techGrid.setAutoFitMaxRecords(22);
With just the above code, clicking the remove icon marks the record for removal and removes the record when the icon that controls 'saveAllEdits()' is clicked. All is well except I want to suppress the behavior for one record value.
So I added this code:
techGrid.addRemoveRecordClickHandler(new RemoveRecordClickHandler() {
@Override
public void onRemoveRecordClick(RemoveRecordClickEvent event) {
int row = event.getRowNum();
Record recRm = techGrid.getRecord(row);
String rule = recRm.getAttributeAsString("TechDescription");
if ( "generic".equalsIgnoreCase(rule)){
SC.warn("No one may remove the <b><i>generic</i></b> Tech Rule Type");
techGrid.unmarkRecordRemoved(row);
}
techGrid.markRecordRemoved(row);
return;
}
} );
Now clicking the remove icon on the row containing the value 'generic' gets a popup warning not allowing the remove. But clicking any other record a) does not mark the record for removal and b) does not cause the record to be removed when saveAllEdits() is called.
Do I have to define a techGrid.removeData() function instead of the simple use of markRecordRemoved()? How can I retain the functionality of marking the records for delete and only executing the delete when saveAllEdits() is called?
Thanks
Comment