Question

Clear Button on Dashboard

  • 15 December 2022
  • 2 replies
  • 315 views

Hi I am struggling to write the code to clear all BAQs on a dashboard when the epibutton ClearAll is clicked.

// **************************************************
// 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 **
    }
}


2 replies

Userlevel 4

I’ve never tried to clear the contents of a grid, and not sure whether grids have a “clear” method.  If so, that’s clearly the thing to do in your OnClick event.  Short of that, I would force something that’s never going to be a part number (maybe the word Clear) into the part number field, and call OnClick of the Refresh All button you’ve created.  If you don’t want the user to see this, you can create a hidden field, linked exactly as your part number field is linked, and load the hidden field up with the “clearing” non-part number value.

 

HTH

...Monty.

I have managed to solve this by using the following

 

EpiUltraGrid myGrid = (EpiUltraGrid)csm.GetNativeControlReference("c7f5dd77-758e-454e-b8f8-a1a9a9c7edcf");
    myGrid.Focus();
    MainController.AppControlPanel.HandleToolClick("ClearTool", new Infragistics.Win.UltraWinToolbars.ToolClickEventArgs(MainController.MainToolManager.Tools["ClearTool"], null));

 

I have repeated this and changed the control reference to point to the other grids.

 

Thank you for your help.

 

Regards

Reply