Clear Button on Dashboard

Hi I am struggling to write the code to clear all grids when the epibutton ClearAll is clicked.

Any help would be great.

// Custom code for MainController
// Created: 15/12/2022 11:52:19
// **************************************************
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Ice.BO;
using Ice.UI;
using Ice.Lib;
using Ice.Adapters;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
using Ice.UI.FormFunctions;

public class Script
{
	// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
	// Begin Wizard Added Module Level Variables **

	// End Wizard Added Module Level Variables **

	// Add Custom Module Level Variables Here **

	public void InitializeCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
		// Begin Wizard Added Variable Initialization

		// End Wizard Added Variable Initialization

		// Begin Wizard Added Custom Method Calls

		this.Refresh.Click += new System.EventHandler(this.Refresh_Click);
		this.ClearAll.Click += new System.EventHandler(this.ClearAll_Click);
		// End Wizard Added Custom Method Calls
	}

	public void DestroyCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
		// Begin Wizard Added Object Disposal

		this.Refresh.Click -= new System.EventHandler(this.Refresh_Click);
		this.ClearAll.Click -= new System.EventHandler(this.ClearAll_Click);
		// End Wizard Added Object Disposal

		// Begin Custom Code Disposal

		// End Custom Code Disposal
	}

	private void Refresh_Click(object sender, System.EventArgs args)
	{
		// ** Place Event Handling Code Here **
		MainController.AppControlPanel.HandleToolClick("RefreshTool", new Infragistics.Win.UltraWinToolbars.ToolClickEventArgs(MainController.MainToolManager.Tools["RefreshTool"], null));

	}

	private void ClearAll_Click(object sender, System.EventArgs args)
	{
		// ** Place Event Handling Code Here **
	}
}```

I have multiple BAQs showing on the grid.

I normally use this bit to clear my grids:

		MainController.AppControlPanel.HandleToolClick("RefreshTool", new 
		Infragistics.Win.UltraWinToolbars.ToolClickEventArgs(MainController.MainToolManager.Tools["RefreshTool"], null));

EDIT: Sorry, that’s refresh, this is clear:

	private void ClearMe()
	{			
		MainController.AppControlPanel.HandleToolClick("ClearTool", new 
		Infragistics.Win.UltraWinToolbars.ToolClickEventArgs(MainController.MainToolManager.Tools["ClearTool"], null));
	}

Hi the only problem with this is it only clears the one grid not all.

I have a tracker where the other grids are then subscribed to it.

Is there a reason you don’t want to use the native clear tool?

Clearing all grids:
ClearUI

I’m not sure why but it doesn’t clear all the grids for me. It only clears the one BAQ and the tracker that’s assigned to it. The other BAQs that are filtered from the first BAQ do not clear.

Interesting.

Well, you could always take part of @NateS’s solution and combine it with a grid focus.

Pseudocode in clear all button click function:
Get grid 1 reference.
Focus the grid.
Code to clear.
Repeat for each grid

You’ve piqued my curiosity, though.
I’m going to see if I can replicate your scenario. :face_with_monocle:

HI Hannah,
will you be able to share this dashboard customization.