Expand Arm items

StatusIDPriorityType
Closed39565MajorQuestion
ProfileReply
KaleClient

How do I expand some arm items
at startup and hide empty arm items.

Replies

UserDescriptionPosted On
MariyaVoytovichAgent

Hello!

I apologize for the delayed response.

There is currently no easy way to expand a node in arm items.
To expand or hide a node, you need to get a tree list control that contains navigation items.
You can see how to do this in the code below.

	public partial class Test2WindowArmController : WindowController
	{
		public Test2WindowArmController()
		{
			InitializeComponent();
			// Target required Windows (via the TargetXXX properties) and create their Actions.
		}
		protected override void OnActivated()
		{
			base.OnActivated();
			// Perform various tasks depending on the target Window.
		}
		protected override void OnWindowChanging(Window window)
		{
			base.OnWindowChanging(window);
			if (!window.IsMain) return;

			this.Frame.TemplateChanged += Frame_TemplateChanged;
		}
		void Frame_TemplateChanged(object sender, EventArgs e)
		{
			if (this.Frame.Template == null) return;
			bool supportArms = this.Frame.Template is ISupportArms;
			this.Active["SupportArmsKey"] = supportArms;
			if (supportArms)
			{
				var containers = this.Frame.Template.GetContainers();
				var armsContainer = containers.FirstOrDefault(x => x.ContainerId == "Arms" && x is ArmItemsActionContainer);

				if (armsContainer is ArmItemsActionContainer armItemsActionContainer)
				{
					var controls = armItemsActionContainer.Controls.Find("treeListItemsActionContainer", true);
					if (!controls.Any())
						armItemsActionContainer.ControlAdded += ArmItemsActionContainer_ControlAdded;
					else
					{
						var treeListItemsActionContainer = controls.First();
					}
				}
			}
		}

		private void ArmItemsActionContainer_ControlAdded(object sender, System.Windows.Forms.ControlEventArgs e)
		{
			(sender as ArmItemsActionContainer).ControlAdded -= ArmItemsActionContainer_ControlAdded;

			TreeListArmsControl treeListArmsControl = e.Control as TreeListArmsControl;
			if (treeListArmsControl == null) return;

			var controls = treeListArmsControl.Controls.Find("treeList1", true);
			if (controls.Any())
			{
				var treeListControl = controls.First();
				if (treeListControl is TreeList treeList)
				{
					var expandNode = treeList.Nodes.FirstNode;
					expandNode.Visible = false;
					//expandNode.Expanded = true;
				}
			}
		}

		protected override void OnDeactivated()
		{
			this.Frame.TemplateChanged -= Frame_TemplateChanged;
			// Unsubscribe from previously subscribed events and release other references and resources.
			base.OnDeactivated();
		}
	}

You can search for a specific node in the tree list like this:

treeList.FindNodeByFieldValue("ItemPath", itemPath)

itemPath - this is the full path to the Arm node in the model.
Let us know if you need further assistance.

Regards,
Mariya
On behalf of Xafari Client Services Team

× This ticket is closed.

Write US