Hide values in a form field when they are equal to default

Hello! I have a form, that allows editing and disallows adding and deleting records of a table. The records are presented with a grid. I would like to hide zeroes from the fields of the grid. I want the grid to show a value only if it is different from the default. (Calc behaves similar - shows cell values only if they contain anything, otherwise cells are empty). How can I achieve it?

Any solutions are considered, including those that require programming and source code modification.

edit retag close merge delete

Sounds like a departure from the native operation of the field controls. You could get the display working by having a query be the record source, and for the row source have something like CASE WHEN x = 'default' THEN '' ELSE x END or alternatively IF(x = 'default', '', x). Updates and inserts would be problematic in that setup, however.

( 2015-03-11 04:14:43 +0200 )edit

Is there any options to implement an alternative field control with required features? Is it possible to do as an extension for LibreOffice? Or it would require hacking LO codebase?

( 2015-03-16 07:32:20 +0200 )edit
1

For a single-record form, could acheive it via two controls for each field, one not visible and bound to the recordset, the other visible and unbounded. Macros could transfer values between the hidden and unhidden controls as desired. Complicated but possible. For a grid, you would need to set the values for non-focus rows, can't be done with macro, would need to use query but that then would interfere with updates on current row. Maybe macro could update by monitoring raw keystrokes.

( 2015-03-22 03:05:14 +0200 )edit

Sort by » oldest newest most voted

Hello @senya,

This can be done per column, by changing the column control into a “Formatted Field” and setting its Format Code so that it hides zeroes:

1. in your Grid control, right-click on the Column Header and select the menu “Replace With : Formatted Field”;
2. Again right-click on the same Column Header and this time select the item “Column...”;
3. in the Properties dialog that pops up, in the tab “General”, to the right of the Editfield that says “Formatting”, click on the ellipsis button “...” ;
4. In the Formatting dialog that pops up, in the Editfield called “Format Code”, enter the string [>0]#;[<0]-#;"";
5. Click OK.

HTH, lib

more