Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Work Tasks

TreeView​.cs

  • Last UpdatedMar 12, 2021
  • 2 minute read

namespace Corp.CustomControls

{

using System;

using System.ComponentModel;

using System.Text;

using System.Web;

using Skelta.Forms.Core.Controls;

using Skelta.Forms.Core.Interfaces;

using Skelta.Forms.Core.PropertyControls;

using Skelta.Forms.Core.CommonObjects;

[DesignerControl(992200, CoreDesigner.NextGenDesigner, DesignerCategory.Control)]

[SuppressedPropertiesNextGen("MobileDisplay;Height;Width;ReadOnly;MessageWhenEmpty;DefaultValue;ExpDefaultValue;OnDataChangedScript;ExpValue;ExpValidate;IncludeInSummaryView;")]

public class TreeView : BaseDataExternalControl

{

public override BaseControl GetNewInstanceForClone()

{

TreeView clonedTreeView = new TreeView();

clonedTreeView.dataLookupDetails = this.dataLookupDetails;

return clonedTreeView;

}

private DataLookupProperty dataLookupDetails = null;

/// <summary>

/// Gets or Sets the configurationDetails property that holds lookup name and the parameter collection

/// </summary>

[DefaultValue(null)]

[DesignerProperty(775000, Categories.Behaviour, CoreDesigner.NextGenDesigner, typeof(DataLookupProperty))]

[BindingAttribute(882700, "Skelta.Forms.Core.CommonObjects.DataLookupBindingProperty")]

public DataLookupProperty DataLookupDetails

{

get

{

return dataLookupDetails;

}

set

{

dataLookupDetails = value;

}

}

/// <summary>

/// Gets or sets the Custom Bindings

/// </summary>

[SerializationVisibility(SerializationVisibilityValues.Hidden)]

[BindingAttribute(882700, true, "Corp.CustomControls.TreeViewBinding")]

public string CustomBindings

{

get;

set;

}

/// <summary>

/// Method to add the custom Js files associated to the custom control

/// </summary>

private void AddJsFiles()

{

// "this.TopLevelForm.RuntimeCss" is the collection which holds your custom CSS files.

// It is a key-value pair collection where the key is the file name and the value is the file path(absolute or relative).

//Important point is the JS file should be present inside "BPMUITemplate/Default/NextGenForms/js" folder or else it won't get rendered.

if (string.IsNullOrEmpty(this.TopLevelForm.RuntimeJS["kendo.treeview"]))

{

this.TopLevelForm.RuntimeJS.Add("kendo.treeview", "js/kendo.treeview.js");

}

if (string.IsNullOrEmpty(this.TopLevelForm.RuntimeJS["corp.customControls.treeView"]))

{

this.TopLevelForm.RuntimeJS.Add("corp.customControls.treeView", "js/corp.customControls.treeView.js");

}

if (string.IsNullOrEmpty(this.TopLevelForm.RuntimeJS["knockout-kendo.treeview"]))

{

this.TopLevelForm.RuntimeJS.Add("knockout-kendo.treeview", "js/knockout-kendo.treeview.js");

}

}

public override string GetControlHtml()

{

AddJsFiles();

StringBuilder stringBuilder = new StringBuilder();

if (!this.TopLevelForm.InDesignMode)

{

StringBuilder dataBindAttribute = new StringBuilder();

stringBuilder.Append("<div" + this.GetControlIdAttribute + " title=\"" + HttpUtility.HtmlEncode(this.ToolTip) + "\"");

dataBindAttribute.Append(" " + DataBindAttribute + "=\"kendoTreeView: {data: " + this.Id + "._source, dataTextField: " + this.Id + "._dataTextField}\"");

stringBuilder.Append(dataBindAttribute.ToString() + ">");

stringBuilder.Append("</div>");

}

return stringBuilder.ToString();

}

public override string GetViewModelScript()

{

StringBuilder viewModelScript = new StringBuilder();

viewModelScript.Append(base.GetViewModelScript());

string controlString = "_" + this.ParentForm.Id + "." + this.Id;

viewModelScript.AppendLine("corp.customControls.treeView.initializeTreeView(" + controlString + ");");

return viewModelScript.ToString();

}

public override IBindingProperty GetBindingClassObject(string fullyQualifiedClassPath)

{

try

{

return (IBindingProperty)Activator.CreateInstance(Type.GetType(fullyQualifiedClassPath));

}

catch (Exception ex)

{

return null;

}

}

}

}

TitleResults for “How to create a CRG?”Also Available in