Add an attribute form to your attribute, using an ApplySimple statement.
Example:
ApplySimple("LPAD(#0,4,'0')",[class_number])
Classify this form as a description form and display it in your report instead of the ID form. This way, the database engine will group by and filter on the ID ([class_number]) and get the padded version (LPAD([class_number],4,'0') in the last pass of the report SQL. You suffer no performance degradation.