I have created an updatable BAQ and put it in a dashboard and it is all working.
I’ve shown the dashboard to my user and now asking me if I can add a Select All button.
There are some topics that I am trying to follow here, but it’s just not working.
Below are the things I have done
Created an Updatable BAQ - making the JobHead_SchedLocked Updatable and query settings is Allow Multiple Row Update
Added it in the dashboard, checking the Updatable checkbox in the Properties
I don’t get any errors when I test code. But when I run the dashboard, do my filters and refresh, then Click the Select All button I added, it does not do anything…
I did my tracker view in the dashboard and the only thing I added in the UI customization is the button and the below codes. I click anywhere on my dashboard summary to get my ControlReference for myGrid.
Thanks!
// **************************************************
// Custom code for MainController
// Created: 8/11/2023 9:42:41 AM
// **************************************************
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;
using Infragistics.Win.UltraWinGrid;
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
// 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
// End Wizard Added Object Disposal
// Begin Custom Code Disposal
// End Custom Code Disposal
}
EpiUltraGrid myGrid
{
get
{
return (EpiUltraGrid)
csm.GetNativeControlReference("883ff389-683c-4faa-b8c9-783d696abb0d");
}
}
private void btnSelectAll_Click(object sender, System.EventArgs args)
{
int cnt = myGrid.Rows.Count;
string msg = string.Format("There are '{0}' rows in the grid. Are you really realy REALLY sure you want to select ALL '{0}' rows? Click Yes to confrim, No to cancel", cnt);
if (MessageBox.Show(msg, "Select all the jobs", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
{
ChangeAll(myGrid.Rows, true);
}
}
public void ChangeAll(RowsCollection row, bool val)
{
foreach (UltraGridRow r in row)
{
if (r.GetType() == typeof(UltraGridGroupByRow))
ChangeAll(((UltraGridGroupByRow)r).Rows, val);
else
r.Cells["JobHead_SchedLocked"].Value = val;
}
}
}
You don’t have anything in “Initialize custom code” which leads me to believe that you just copied the functions from below. Those don’t fire unless something calls them, and since you didn’t initialize and subscriptions nothing is calling them.
For button clicks, use the wizard to add the button click function, then put the code from btnSelectAll_Click into the function that epicor makes for you. The wizard will add what you need for the button click to work.
This is my working code now. Just make sure you add the btnSelectAll_Click in the Event Wizard cause that is what I’m missing before. Thanks!
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;
using Infragistics.Win.UltraWinGrid;
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.btnSelectAll.Click += new System.EventHandler(this.btnSelectAll_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.btnSelectAll.Click -= new System.EventHandler(this.btnSelectAll_Click);
// End Wizard Added Object Disposal
// Begin Custom Code Disposal
// End Custom Code Disposal
}
EpiUltraGrid myGrid
{
get
{
return (EpiUltraGrid)
csm.GetNativeControlReference("883ff389-683c-4faa-b8c9-783d696abb0d");
}
}
private void btnSelectAll_Click(object sender, System.EventArgs args)
{
int cnt = myGrid.Rows.Count;
string msg = string.Format("There are '{0}' jobs that you are about to lock. Are you sure you want to lock ALL '{0}' jobs? Click Yes to confirm, No to cancel", cnt);
if (MessageBox.Show(msg, "Select all the jobs", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
{
ChangeAll(myGrid.Rows, true);
}
}
public void ChangeAll(RowsCollection row, bool val)
{
foreach (UltraGridRow r in row)
{
if (r.GetType() == typeof(UltraGridGroupByRow))
ChangeAll(((UltraGridGroupByRow)r).Rows, val);
else
r.Cells["JobHead_SchedLocked"].Value = val;
}
}
}