Knowledge Base
  • Introduction
  • Events and Actions
  • Action Panel
  • sending email
  • calling a SQL action from a client side js action
  • Accessing to translations form a server
  • Executing SQL statements from within an action
  • How to invoke a generic SQL statement defined through a SQL action
  • How to show a message dialog
  • checking for "undefined" values
  • How to add spaces to the right of a text
  • How to create a docx report and show it on the web browser Enterprise Edition only
  • How to get or set a value from the graphics control
  • How to invoke a generic SQL query defined through a business component
  • How to remove spaces to the left and right of a text
  • How to support multiple themes in a single application, accoding to a rule
  • How to set content to a Google Map linked to a grid or form
  • How to replace all occurences of a pattern from a text
  • Utility methods
  • Link auto login
  • Creation of a link for the first access of a new user without give the user a password and forcing
  • Forgot password
  • setting up default values from values coming from a filter panel
  • identifing the modified record after the alteration
  • enabling/disabling checkboxes in a grid
  • Filtering a Lookup
  • formatting a column
  • using checkboxes to select rows in grid
  • showing a summary row in grid
  • Disabling a toolbar button
  • Configuring grid exports
  • Adding filter conditions to a grid
  • Filtering the grid content from a tree
  • Filtering the tree content, starting from a filter panel linked to a grid
  • collapsing a panel
  • validating a lookup
  • accessing the authorizations set for a specific grid
  • How to design a web service
  • How to remotelly invoke an action or business component or perform a write operation through a Restf
  • how to feed a grid from a JS business component
  • converting a JS object to a JSON string
  • executing a query
  • passing parameters to a server side JS action
  • return value
  • scheduling and frequency
  • finding the right filter panel
  • checking out if a component has been defined
  • Deploying an application
  • Enquiring a table belonging to the Platform repository
  • Adding a where clause to a business component linked to grid
  • Integrating Mailchimp lists
  • Formatting a number as a currency value to use it inside an email template
  • sending email from a template
  • How to send an email
  • Error 'smtpHost' is empty
  • Linking two windows
  • How to open manually a window from another window
  • How to open manually a popup window
  • How to hide a panel in a window dinamically
  • How to manage folder panels
  • How to manage card panels
  • Predefined variables supported by Platform
  • Accessing the application parameters
  • Application Log
  • How to design a web service
  • How to import java classes in server
  • How to import java classes in server
  • How to dynamically set a value on a combo
  • 4WS.Platform
  • How to listen to events in a mobile HTML panel
  • Issues with HTTPS requests
  • How to manage row totals in grid
  • How to send to the UI a notification to execute code automatically
  • How to filter a chart by date interval
  • How to filter a grid by date interval
  • How to read a text or csv file and save data on the database
  • How to write text or csv files
  • Reading an xls file stored in the specified path
  • How to create a report with Jasper Report
  • How to customize the alert message content
  • Setting up a cluster
  • Uploading and downloading files
  • How to listen to user definition changes
  • How to auto-show a window from login
  • How to manage encrypted fields
  • How to change CSS settings for a grid row
  • Customizing a Tree Panel
  • How to execute complex queries on Google Datastore
  • Theme customization
  • Retrieve and send the log of a mobile app
  • Import Roles and Users
  • How to synchronize multiple Form panels in the same window
  • Anchor buttons
  • Properties of subpanels
  • Bulk import
  • How to display the data not found message in a grid
  • How to setup an LDAP based authentication
  • How to synchronize data from Datastore to BigQuery
  • How to synchronize data from Datastore to Google Spanner
  • How to synchronize data from Datastore to CloudSQL
  • Scrollable form list
  • How to setup SAML authentication
  • How to export data from BigQuery in streaming
  • Update Google Spreadsheet
  • How to setup OAuth2 authentication
Powered by GitBook
On this page

Was this helpful?

How to filter a chart by date interval

In case you have configured a chart panel, what you have already done is:

  • define a business component, usually a "SQL based component for a grid" to fill in the chart

  • define a window containing the chart panel and bind that business component in the chart panel definition

After that, you have a dynamic chart, whose content depends on the bind variables defined in the SQL business component, which could be something like:

SELECT ... FROM ... WHERE FIELD1 = :COMPANY_ID

where :XXX are input parameters which can be automatically resolved by Platform in case of predefined variables (e.g. COMPANY_ID, SITE_ID, USERNAME, ...) or can come from the UI.

A window composed of a filter panel + chart panel

When you need for dynamic content in a chart, it is a good practice to include in the window a filter panel as well.

That means you have to manually add filter components to the filter panel, whose name must be exactly as a database field which can be appended to the base SQL statement defined in the business component. These filter components must also have selected the "Add to filter" flag, in order to automatically pass forward such filter conditions.

When the end user presses the Search button in the filter panel, Platform will pass forward to the server-side these request parameters:

  • filterNames - a String composed of a list of attribute names separated by a comma; example: "field1,field2,"

  • filterOps - a String composed of a list of operators to apply to the filters defined above and therefore they must have the same number of tokens, separated by a comma; example: "=,>=,"

  • filterCaseSensitives - a String composed of a list of boolean flags, separated by a comma, one for each filter defined above, indicating whether a text valu filter must be CASE sensitive or not; example: "false,false,"

  • filterValues - a String composed of a list of attribute names separated by a comma; example: "ABC,2,"

Suppose you have defined a filter component having field name: "FIELD3", with operator "like".

When such a filter has been filled on the web UI and the user has pressed the Search button, Platform will pass forward something like:

  • filterNames = "field3,"

  • filterOps = "like,"

  • filterCaseSensitives - "false,"

  • filterValues - xyz

On the server side, the base SQL statement will be enriched with this additional condition:

SELECT ... FROM ... WHERE FIELD1 = :COMPANY_ID AND FIELD3 LIKE xyz

Filling additional bind variables

A more complex scenario is when you have defined a SQL statement in the business component requiring bind variables not directly solved by Platform (not predefined variables).

Suppose you have defined a SQL statement like the following:

SELECT ... FROM ... WHERE FIELD1 = :COMPANY_ID AND MY_DATE >= :DATE1 AND MY_DATE <= :DATE2

For this example, two filter components must be defined, which can be called for example DATE1 and DATE2; pay attention to NOT select the flag "Add to filter", otherwise Platform will automatically pass these filter conditions to the business component, where the base SQL would be enriched with:

AND DATE1 = ... AND DATE2 = ...

but DATE1 and DATE2 are NOT real database fields and a database error would be fired!

The bind variables required by the business component linked to the chart panel (DATE1 and DATE2) can be filled by passing them forward through the filter panel, using a "before search" event linked to the filter panel.

In such client-side javascript action, you can define or even by-pass completely the filter conditions to pass to the business component: filterNames, filterOps, filterCaseSensitives, filterValues.

You can append additional filters to these pre-filled variables, as well as completely redefine them.

You can also pass forward additional bind variables, not defined through a filter component.

The right content for such js action could be:

var date1 = getComponentByItemId('filterPanelxxx',win).getComponent('controlDATE1');
var date2 = getComponentByItemId('filterPanelxxx',win).getComponent('controlDATE2');
if (date1.getValue()!=null && date2.getValue()!=null) {
    baseParamsChartPanelyyy.date1 = date1.getValue();
    baseParamsChartPanelyyy.date2 = date2.getValue();
}

Through this scriptlet, the two dates are read from the filter components and passed forward to the server-side as 2 request parameters named date1 and date2.

Please note that yyy represents the id of the chart panel, whereas xxx represent the id of the filter panel.

Important note: bear in mind that you have always to set the right input parameter type in the business component: when you edit the business component content, by adding bind variables like :DATE1 and :DATE2, Platform will automatically identify them and include them in the "Component input parameters" folder. Here you have to set the right parameter type. For the example above, you have o change the parameter type to Date for DATE1 and DATE2, otherwise the 2 strings passed from the UI related to the dates, will not be correctly converted to dates!

PreviousHow to send to the UI a notification to execute code automaticallyNextHow to filter a grid by date interval

Last updated 5 years ago

Was this helpful?