Specifying Criteria/Filters in Views

 

Creating Views

By default, all the entries in a form will be displayed in the view. Default filters will be created for single-select, multi-select and date fields. The Deluge syntax to display all the rows in a form with default filters, is given below.

Syntax

list  <"View Name">
{
    show  all  rows  from  < Form Name > 
    (
        < Field name >
        < Field name >
        < Field name >
        < Field name >
        
    )
    filters 
    (
        < Single select/Multiple select Field name >
        < Single select/Multiple select Field name >
              
    )
} 
      

Base criteria

While getting a book from the library, you will definitely like to first look at the books list that has not been issued to anybody. This is a often required feature. This can be easily achieved by setting matching criteria while creating views. To specify the base criteria in script mode, add the required criteria to your view definition as highlighted in the code below. In the above code, only those records in the Employee_Form whose Department is HR can be viewed by the user. If the base criteria is not specified, all the records can be viewed by the user.

list  Employee_Form_View
{
displayname = "Employee Form View"
show all rows from Employee_Form [Department == "HR"]
(
Employee
Phone
Date_of_Birth as "Date of Birth"
Postal_Address as "Postal Address"
Date_of_Joining as "Date of Joining"
Department
)
filters
(
Date_of_Birth
Date_of_Joining
Department
)
}

To specify the criteria from GUI, select the view from the View Tab and select Set Criteria option displayed on the left-side tree. The criteria specified in the GUI will be automatically added to the view definition, in script mode. Refer FAQ -> View Builder to configure criteria in views.

Auto Filter

Filters are a set of named criteria that allows you to select only specific entries in a view. Default filters will be created for single-select and multi-select fields. The Deluge syntax to display all the rows in a form with default filters, is given below.Zoho creator creates default filters for the fields belonging to any of the following types. These filters are called "Auto filters".

  • user defined or import data single select
  • user defined or import data multiple select
  • date

It is enough to just specify the name of the field as the filter, as specified in the sample code below. For example:
list  Employee_Form_View
{
displayname = "Employee Form View"
show all rows from Employee_Form [Department == "HR"]
(
Employee
Phone
Date_of_Birth as "Date of Birth"
Postal_Address as "Postal Address"
Date_of_Joining as "Date of Joining"
Department
)
filters
(
Date_of_Birth
Date_of_Joining
Department
)

}

In the Zoho Creator GUI mode, the default filters will be displayed. You can enable/disable the auto filters by selecting/deselecting the show checkbox. By default, it is enabled.

In Live mode, the filters will be displayed in the Filter list-box as shown below. The name of the field will be taken as the name of the filter. The values for the fields will get displayed in the Filters drop down list. Selecting a filter name, will display only those records that satisfy the filter criteria. For example, in the Employee View, if Department is selectetd as "Engineering", the only those employees in the Employee form whose department is "Engineering" is listed, as shown below.

 

Custom Filter

Custom filters are a set of named criteria that can be defined by the user. At present, only simple criteria can be defined in the GUI mode. See the image below.

It only has match alland match any. The deluge script generated for the above custom filter is highlighted below:

filters 
(
Date_of_Birth
Date_of_Joining
Department
"ID/Dept." : (ID >= 50 && Department == "Engineering")
)

To define slightly complex ones, like having both a AND and an OR operator, deluge scripting is needed. See the sample given below:

filters 
(
Date_of_Birth
Date_of_Joining
Department
EducationQualification
Experience
"ID/Dept." : (ID >= 50 && Department == "Engineering")
"Diploma/PostGraduate" : ((EducationalQualification == "Diploma" && Experience == "2 years") || Educational
Qualification == "PostGraduate")

)
}

Here "Diploma/PostGraduate" is the name of the custom filter which uses both the AND (&&) and OR (||) operator to create the criteria expression. To know more about the expressions in deluge scripting, refer to Expressions.

 

Related Links

Tips & Tricks - Filtering Data in Views