ObjectGears Help

           
Forum   ObjectGears (Version: 1.6.0.0)

Data filtering

 Quick filter

It is possible to specify attributes that can be used in the quick filter and state default value of each attribute in the filter. When the record list of the class is displayed, there are records filtered according to these settings. The user can then clear the filter or change  it.

A substitute sign % can be used for search.

Example:

abc – searches records that contain in the given column text  abc

"abc" – searches records that contain in the given column exact text  abc

"abc%" - searches records where the given column starts with text  abc

"%abc" - searches records where the given column ends with text  abc

"ab%c" - searches records where the given column starts with text  ab   and ends with text c

 

Filter on a button

It is possible to use a button in the list of records which will set the filter to the requested values.

We will create a button of the type Script:

//clears possible existing filter
OGFilter.Clear();

// sets the filter to the requested values
OGFilter.Add( true, 'status', '!=', 'resolved');
OGFilter.Add( true, 'status', '!=', 'deferred');
OGFilter.Add( true, 'status', '!=', 'canceled');
OGFilter.Add( true, 'status', '!=', 'todeploy');
OGFilter.Add( true, 'assignto', '=', OG.Person.GetLoginPerson());

//applies the filter
OGFilter.Run();

//packs the block with filter
OGFilter.Minimize();

The resulting filter block looks after clicking like this:

You use following values/objects in the last parameter of the method OGFilter.Add:

Filter on a button 2

The following example creates a filter with brackets.

// Column Name contains word 'calendar' and column Status equals New, For testing or To provide more information

//clears possible existing filter
OGFilter.Clear();

// sets the filter to the requested values
OGFilter.Add( true, 'name', 'contains', 'calendar');
var stav = OGFilter.AddBracket( true);
OGFilter.Add( status, false, 'status', '=', 'New');
OGFilter.Add( status, false, 'status', '=', 'For testing');
OGFilter.Add( status, false, 'status', '=', 'To provide more information');

//applies the filter
OGFilter.Run();


The resulting filter block looks after clicking like this:

 

Filter on a button 3

The following example creates a filter displaying records only from certain child classes of the class in which we are filtering. In case of more complex class hierarchy (child class has also child classes) we can e.g. filter records from one child class except for records belonging to a certain child class of this child class.

// Displays records only from the child class All applications but not from the its child class System applications

//clears possible existing filter
OGFilter.Clear();

// sets the filter to the requested values
OGFilter.Add( true, '<child>', '=', 'all-applications');
OGFilter.Add( true, '<child>', '!=', 'system-application');

//applies the filter
OGFilter.Run();

The resulting filter block looks after clicking like this:

 

Filter at displaying list of records

The following example applies filter when displaying class/query list of records displaying only records with value in column 'To' that is greater than or equal to current date. The user can then see only current records, not that ones relating to past activities. The below script has to be placed in a class/query detail on tab Script - List of records.

function OnLoad()
{
// Filters records with 'to' greater than or equal to today
  if ( !OGForm.Page.IsPostBack)
  {
    OGFilter.Clear();
    OGFilter.Add( true, 'to', 'in interval', 'today');
    OGFilter.Add( false, 'to', '>=', 'now');
    OGFilter.Run();
  }
}

The resulting filter block looks after clicking like this:

If we want to enable user to save a link to records including filter from menu Favourites and apply this filter when using the link, it is necessary to use a condition in the script: ( !OGForm.QueryString.Exist('filter')). This will cause that if there is a filter defined in URL, the filter from the script will not be applied and filter from the URL will be used instead.

function OnLoad()
{
// Filters records with 'to' greater than or equal to today
  if ( !OGForm.Page.IsPostBack)
  {
  if ( !OGForm.QueryString.Exist('filter'))
    {
       OGFilter.Clear();
       OGFilter.Add( true, 'to', 'in interval', 'today');
       OGFilter.Add( false, 'to', '>=', 'now');
       OGFilter.Run();
    }
  }
}

 

Example of filtering according to values in columnPříklad filtrován podle hodnoty ve sloupci Value from a referenced class (various classes):

 function OnLoad()
 {
   if ( !OGForm.Page.IsPostBack && !OGForm.QueryString.Exist('filter'))
   {
     OGFilter.Clear();
     OGFilter.Add( true, 'x-classlink-n', '=', '543-4');
     OGFilter.Run();
   }
 }

This website is using cookies files to provide services and analyse visits. You agree with that by using this website.     Further information