Let’s say you have a report that has some filter controls on top that let you narrow the scope of the report. When the report loads, the filter is collapsed. The user opens the filter, changes some of the settings, and submits the form. What is the preferred method for determining whether the filter should be displayed? A related question is whether you should detect the filter’s visibility status in JavaScript or you should check on the server side and use the style
attribute to control visibility.
Here are some options:
- Always leave the filter collapsed initially. I hate this option, though, because it hides important information from the user. If the report is in some non-default state, the user should be able see when it loads what that state is.
- Check to see whether any form parameters were submitted. If there were, add the appropriate
style
attribute to the form on the server side. - Assuming the GET method was used, check for a query string in JavaScript and hide the form using JavaScript if no query string is present. (Indicating that the filter is in its default state.)
- Using JavaScript, check the values of all of the fields on the form to see whether they are in their default state. If not, display the form.
- Use a hidden form field set on the server side to indicate that the filter should be displayed. In JavaScript, check that field to determine whether or not the filter should be displayed.
There are probably other options as well, and all of them will work. Choosing from among them is a matter of ease of maintenance, mostly. Ideas?
Links from July 9th