ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / Developing an application or website / Controls, windows and pages / Controls: Available types / Dashboard control
  • Overview
  • Manipulating Dashboard controls programmatically
  • Adding a widget
  • Running a procedure defined for an internal window or page (used as widget)
  • Handling a widget programmatically
  • Dragging and dropping widgets onto a Dashboard control
  • Properties specific to Dashboard controls
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Manipulating Dashboard controls programmatically (prefix syntax)
Overview
To programmatically handle a Dashboard control, WINDEV, WEBDEV and WINDEV Mobile include dashboard-specific functions.
This help page explains how to programmatically manipulate Dashboard controls.
Linux Note: The Dashboard control is only available in Linux for WEBDEV Linux sites. Dashboard controls are not available in WINDEV applications for Linux.
Manipulating Dashboard controls programmatically

Adding a widget

Widgets can be added to Dashboard controls using <Dashboard>.AddWidget. By default, a Widget is invisible. It can be displayed by using the Visible property. If the widget is not visible, the user can make it visible via the context menu of the edit mode.
Examples:
  • Adding a simple widget (without parameters):
    // Ajoute un Widget simple
    nIndice = TDB_TableauDeBord.AjouteWidget(FI_Widget_AlerteStock, "Alerte stock")
  • Adding a widget with parameters:
    nIndice is int
    
    // Ajoute un widget qui attend des paramètres
    nIndice = TDB_TableauDeBord.AjouteWidget(FI_Widget_Horloge, ...
    	"Horloge " + COMBO_AjoutWidget[COMBO_AjoutWidget].ValeurAffichée, ...
    	COMBO_AjoutWidget[COMBO_AjoutWidget].ValeurAffichée)
    
    // Affiche ce widget à la demande
    IF YesNo(Yes, "Souhaitez-vous afficher ce widget ?") = Yes THEN
    	TDB_TableauDeBord[nIndice].Visible = True
    ELSE
     	ToastDisplay("Widget ajouté au tableau de bord en ""caché"". "+ ...
    	"Passez en mode édition pour l'ajouter", toastShort, vaMiddle, haCenter)
    END
Special case: adding a Widget to the initial configuration
By default, the Dashboard control displays the widgets as they have been defined in the window or page editor.
To add widgets programmatically when the Dashboard control is loaded, use:
Warning: in this case, these functions must be used in the "Initialization" event of the Dashboard control array.
Examples:
  • Adding a simple widget (without parameters)
    // --- Initialisation du champ TDB_TableauDeBord
    // - alerte de stock
    // Ajoute le widget
    nIndice = TDB_TableauDeBord.AjouteWidget(FI_Widget_AlerteStock, "Alerte stock")
    // Configure le widget (calé à gauche)
    TDB_TableauDeBord.ConfigurationInitiale(nIndice, 5, 1)
  • Adding a widget with parameters
    // --- Initialisation du champ TDB_TableauDeBord
    
    dDate is Date
    nIndice is int
    nX, nY are int
    
    // Ajoute des informations dans la configuration initiale :
    // - chiffres clés des 3 derniers mois
    nX = 1 ; nY = 3
    FOR i = 1 TO 3
    	// Ajoute le widget
    	nIndice = TDB_TableauDeBord.AjouteWidget(FI_Widget_ChiffreClé, ...
    		StringBuild("Chiffres clés de %1", ...
    		dDate.ToString("Mmm AAAA")), dDate)
    	// Configure le widget (calé à gauche)
    	TDB_TableauDeBord.ConfigurationInitiale(nIndice, nX, nY)
    	// Le prochain sera plus bas
    	nY++
    	dDate.Month--
    END
Note: To refresh a Widget with parameters, it is advisable to:
  • Add an optional event for refreshing the widget in the events of the internal window or page.
  • Enter the code used to refresh the widget. This code can be used for example to update the elements displayed in the internal window or page.
  • Refresh the widget with <Dashboard>.Display.

Running a procedure defined for an internal window or page (used as widget)

To run a procedure defined in the internal window or page used as widget, use the following syntaxes:
  • Syntax that uses the name of internal window or page:
    NameInternalWindow.ProcedureName(Param1, Param2, ...)

    For example:
    IW_Widget_KeyNumber.NewDate(EDT_Date)
  • Syntax that uses a Control variable (if the same internal window or page is used several times in the Dashboard control):
    VariableName is Control <- DashboardName[WidgetIndex]
    VariableName.ProcedureName(Param1, Param2, ...)

    For example:
    X is Control <-TDB_TableauDeBord[4]
    X.NouvelleDate(SAI_Date)
Handling a widget programmatically
To programmatically handle a widget, use one of the following syntaxes:
  • Syntax 1: Direct use of the Dashboard control:
    DashboardName[WidgetIndex]

    For example:
    Trace(TDB_MonTableauDeBord[1].Libellé)
  • Syntax 2: Using a variable of type Field:
    VariableName is Control <- DashboardName[WidgetIndex]

    For example:
    X is Control <-TDB_TableauDeBord[4]
    Trace(X.Libellé)
The properties that can be used on widgets are identical to those that can be used on internal windows or pages. For more details, see Properties associated with the internal windows and Properties associated with the internal pages.
Dragging and dropping widgets onto a Dashboard control
WINDEV WINDEV allows you to drag and drop Image, List Box and Looper controls (among others) onto a Dashboard control.
Follow these steps:
  1. Declare that the Dashboard control is the drop target.
    This declaration is made in the initialization code of the control via the DndTarget property.
    Example:
    // -- Initialisation de TDB_TableauDeBord
    // Autorise le Drag and drop
    MySelf.DndCible = dndAuto
  2. Declare that the Dashboard control is the drag source.
    In the initialization code of the source control, declare that the control is the drag source with the DndSource property.
    Example:
    // L'image est source de Drag and Drop
    MySelf.DndSource = dndProgram
  3. Define the procedure to start the drag operation (e.g. in the initialization code of the Source control).
    Example:
    // Définit une procédure pour le "début de glisser"
    // Cette procédure utilise la fonction DnDDonneElementTdb 
    // pour définir le widget à dropper
    DnDEvent(onDndDebut, MySelf, dndBeginDrag)
  4. Type the code of the procedure.
    Example:
    PROCEDURE onDndDebut()
    
    // Selon le champ source, il faut définir le widget à dropper
    SWITCH _DND.SourceControl
    	// Indique que le drop sur le champ Tableau de bord 
    	// doit ajouter le widget "Horloge" 
    	// en utilisant la fenêtre interne "FI_Widget_Horloge"
    	CASE IMG_Widget_Calendrier.Nom
    		DnDCacheDashElement(FI_Widget_Calendrier, "Horloge")
    
    	OTHER CASE
    		Error("Seule l'image IMG_Widget_Calendrier" + ...
    			"est autorisée pour le Drag and Drop")
    END
Properties specific to Dashboard controls
Use the following properties to programmatically manipulate Dashboard controls.
CompactOptionThe CompactOption property is used to:
  • determine whether the options of a Check Box, Radio Button or Dashboard control are compacted.
  • define whether the options of a Check Box, Radio Button or Dashboard control should be compacted.
ElementHeightThe ElementHeight property is used to:
  • Find out or modify the height of the elements in an Organization Chart control.
  • Find out or modify the height of the cells in a Dashboard control.
ElementWidthThe ElementWidth property is used to:
  • Find out or modify the width of the elements in an Organization Chart control.
  • Find out or modify the width of the cells in a Dashboard control.
MarginHeightThe property MarginHeight property property allows you to:
  • Find out the vertical margin between the widgets found in a Dashboard control.
  • Modify the vertical margin between the widgets found in a Dashboard control.
MarginWidthThe property MarginWidth property allows you to:
  • Find out the horizontal margin between the widgets found in a Dashboard control.
  • Modify the horizontal margin between the widgets found in a Dashboard control.
For a complete list of WLanguage properties that can be used with Dashboard controls, see Dashboard control properties.
Minimum version required
  • Version 23
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 09/20/2024

Send a report | Local help