Promotic
WikipediaLinkedInYoutubeTwitterFacebook

GetCfg - method of object TrendsView

Description:
Returns current values of configuration data of the viewer and displayed treds.
Syntax:
GetCfg(sFilter As String, sCfgTitle As String) As String
Calling:
sCfg = oTView.GetCfg(sFilter, sCfgTitle)
Parameters:
sFilter(String) Specifies which of the viewer properties are saved into the configuration data.

The individual values can be concatenated. Example: "View;Trends;TimeMinMax;".

"View;" - Save the viewer appearance apart the tvTrend objects and apart the time of the left and right edge of the viewer.
"Trends;" - Save only the configuration of the tvTrend objects without data points
"TrendsNoConnect;" - Save only the configuration of the tvTrend objects without data points and parameters of the connection. The parameters of the connection are specified by the ConnectionType, ConnectionServer, ConnectionGroup and ConnectionItem properties of the tvTrend object. This option is suitable for generating the configuration file for printing. Note! If some of the following trend properties (for example tvTrend.Name, tvTrend.Unit, tvTrend.ValueMin, tvTrend.ValueMax or tvGraph.Color), contains the string $default (indicating reading the value from the server), then the string will be replaced by the real value that was read (cannot be read without the connection).
"TrendsData;" - Save only data points currently read by the viewer of the tvTrend object without the configuration of this object. This option is suitable for generating the configuration file for printing.
"TimeMinMax;" - Save the time of the left and right edge of the viewer.
"TimeZoom;" - Save only the length of viewer time axis.
sCfgTitle(String) User-defined configuration name. Saves into read data (tag <cfgtitle>). If the configuration is displayed in configuration list (by LoadCfg) the user-defined configuration name is also displayed. Empty string ("") means that the configuration has no user-defined name.
Return Values:
The method returns String containing the complete requested configuration. The configuration data is saved as XML. It can be edited by any text editor and re-read into the viewer by the LoadCfg method.
Example:
An example of saving trend configuration from the viewer to the server. The trend viewer may run on local application (on serveru) or on a Web browser type client (InternetExplorer, Firefox, Chrome ..), but the configuration is alway saved to the server (oposite to the SaveCfg method that saves the data locally).

The example is divided into:

- the script (JavaScript or VBScript) that is activated in the panel from another item (e.g. PmiButton)
- the script on the server in created user method of the panel named "SaveTrendCfg"
-------------------------
An example in JavaScript syntax:
var oTView = pMe.Items("../AxTrendsView").Acx;
var sCfg = oTView.GetCfg("Trends;TimeZoom;", "");
if(Pm.IsValid(sCfg))
{
  if(pMe.PmPanel.Methods.SaveTrendCfg("SaveCfg.tg", sCfg))
    Pm.MessageBox("Message OK", "Configuration file saved");
  else
    Pm.MessageBox("Message Error", "Configuration file NOT saved");
}
-------------------------
An example in VBScript syntax:
Dim oTView, sCfg, bSave
Set oTView = pMe.Items("../AxTrendsView").Acx
sCfg = oTView.GetCfg("Trends;TimeZoom;", "")
If Pm.IsValid(sCfg) Then
  bSave = pMe.PmPanel.Methods.SaveTrendCfg("SaveCfg.tg", sCfg)
  If bSave Then
    Pm.MessageBox "Message OK", "Configuration file saved"
  Else
    Pm.MessageBox "Message Error", "Configuration file NOT saved"
  End If
End If
-------------------------
And the script in the user method of the panel "SaveTrendCfg" with parameters sFile and sCfg (VBScript syntax). The user test for $ADMIN is a security measure that allows only the application administrator to save configurations to the server.
  pResult = Pm.FileTextWrite("#cfg:" & sFile, sCfg, "mode:new;charset:utf-8;")
Else
  pResult = false
End If
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice