Well here is the brief version. It’s relatively simple, it just requires a customization on a dashboard - preferably a “SmartClient” assembly.
You just get a ref to the grid by gettings it’s GUID. Then using:
var myGrid = (WhateverTypeItIsHere)csm.GetNativeControlReference("the GUID here");
//You'll iterate all the rows and check\uncheck them... but also rememeber to dirty them with RowMod
foreach(var row in myGrid.Rows)
{
row.Cells["MyColName"].Value = true;
row.Cells["RowMod"].Value = "U";
}
//You can also do it by using just the epiDataView that feeds the grid (look at it's EpiBinding):
var myEDV = oTrans.Factory("TheDataViewName")
foreach(var row in myEDV.dataView)
{
row["MyColName"] = true;
row["RowMod"] = "U";
}
//finally, notify the UI (you can target the exact one, or use a shotgun blast as shown below):
oTrans.NotifyAll();
this is one method i use in some cases for select all, clear all. It will also work with groupings as those introduce some variability. I have since learned a better way (shown to me by another knowledgeable colleague). For your reference;
private void btnHSelect_Click(object sender, System.EventArgs args)
{
if (myGrid.Selected.Rows.Count > 0)
{
foreach (UltraGridRow dr in myGrid.Selected.Rows)
{
dr.Cells["Print"].Value = true;
}
}
else
{
MessageBox.Show("You must have rows selected in order to set for printing, please play again!");
}
}
So Back to @SimpsonGranco you will have to Deploy your Dashboard. Create a Menu ID via Menu Maintenance, set it as Dashboard Type: Assembly. Then once you restart your Epicor client it will show up on the Menu. Then you can put a Customization Layer on it.
Private Sub btnSelectAll_Click(ByVal sender As Object, ByVal args As System.EventArgs)
ChangeAll(myGrid.Rows, True)
End Sub
Private Sub btnClearAll_Click(ByVal sender As Object, ByVal args As System.EventArgs)
ChangeAll(myGrid.Rows, False)
End Sub
Public Sub ChangeAll(ByVal row As RowsCollection, ByVal val As Boolean)
For Each r As UltraGridRow In row
If r.[GetType]() = GetType(UltraGridGroupByRow) Then
ChangeAll((CType(r, UltraGridGroupByRow)).Rows, val)
Else
r.Cells("Print").Value = val
End If
Next
End Sub
Private Sub btnHSelect_Click(ByVal sender As Object, ByVal args As System.EventArgs)
If myGrid.Selected.Rows.Count > 0 Then
For Each dr As UltraGridRow In myGrid.Selected.Rows
dr.Cells("Print").Value = True
Next
Else
MessageBox.Show("You must have rows selected in order to set for printing, please play again!")
End If
End Sub
FWIW… if you notice performance issues because you’re selecting a huge number of rows, you can improve this by turning off row synchronization (infragistics mumbojumbo)
essentially you start with
// turn it off
myGrid.BeginUpdate();
myGrid.SuspendRowSynchronization();
// do stuff to your rows here
//turn it back on
myGrid.ResumeRowSynchronization();
myGrid.EndUpdate();
SuspendRowSynchronization and ResumeRowSynchronization methods can be used to temporarily suspend UltraGrid from responding to data source change notifications. When row syncrhonization is suspended, the UltraGrid will still mark the rows dirty so it will re-create the rows next time it gets painted.
EndUpdate Resets the Infragistics.Win.UltraControlBase.IsUpdating flag to false and optionally invalidates the control. You can pass a boolean to it.
Overall, it makes your updates faster, so the Grid doesnt repaint itself for every row, do the batch work, then repaint once.
So I was just about to begin toying with this when I noticed that your example selects rows and not checking the boxes on each row… Sorry, as you can tell, I’m not exactly a coder but can get by once started… lol
I got this to work for me, but I have multiple tabs. Is there any way to make 1 button work for whatever the currently active tab is it easier to just create separate buttons for each tab? If separate tabs, is there a way to make the buttons inactive if you are not on the respective tab?