Set a default value to Column Filter

1- Introduction

Sometimes we need to have filters by default that are loaded when entering the screen, so that we do not have to enter them every time we want to search by the same value.

For example, suppose we have a transaction which has different states loaded into an attribute, states like: "open", "closed", "waiting", etc. As they are fixed values, we can load them into a domain with enumerated values.

Every time we visualize the records, we want to show one of these states by default, to facilitate the user's task. The solution we propose is to load an 'Enum Value' by default in the column filters.

2- Requirements

  • This works only if you have Optimization Number = 8

3- Setting values

Open the web panel generated by WorkWithPlus for the "Default List", for example: ProjectWW.  Go to Events tab and look for 'LoadRegFiltersState' Sub.

At start of this subroutine, add the following code (replace all <ATT_NAME> for the attribute name):

If &HTTPRequest.Method = HTTPMethod.Get
  &TF<ATT_NAME>_Sels = new()
  &TF<ATT_NAME>_Sels.Add(Status.Open) //Default Enum Value that you want as default
  WWP_GridStateAddFilterValue(&GridState, !"TF<ATT_NAME>_SEL", true, 0, &TF<ATT_NAME>_Sels.ToJson(), '')
EndIf

It has to look like this:

ColumnTitleDefault1

4- Running example:

ColumnTitleDefault2