So I’m going to lay out the steps that I think I need for this.
Under Add Custom Module Level Variables Here, I need to define my variables right? So I need to 1. name my grid, 2. define the string for the job number,3. and name the text box that I am using.
// Add Custom Module Level Variables Here **
string strJobNum;
EpiUltraGrid MyGrid;
EpiTextBox JobFilter;
So then under the initialize custom code line I need to tell the system what grid it is actually looking at using the EpiGuid.
So this:
myGrid = (Ice.Lib.Framework.EpiUltraGrid)csm.GetNativeControlReference("b3e2940f-c81e-4838-9d16-90eff26f2e04");
And then turn the filtering on by this command:
myGrid.DisplayLayout.Override.AllowRowFiltering = DefaultableBoolean.True;
However when I test the code I get this error:
Error: CS0103 - line 36 (229) - The name ‘DefaultableBoolean’ does not exist in the current context
So I googled that command and found out that it belongs to Infragistics.Win namespace, so I added that in the using and that error went away
using Infragistics.Win;
I also added Infragistics.Win.UltraWinGrid for the FilterComparisionOperator command to be found.
Then I added the clear filter command in the else part of the on leave event so it someone removes everything it clears the filter.
MyGrid.Rows.ColumnFilters["JobNum"].FilterConditions.Clear()
It works really well, just type in what you want and hit tab (just like everywhere else in E-10) and it filters it.
If anyone is interested, Below is the full code so you can see it in context. If someone see something in there that will cause me a problem, I would be very appreciative of the heads up.
One last problem that I have to fix is, I had to move the grid to make room for the text box. When I did that, it seemed to have lost it’s anchors so the size of the grid is now very tall and wide, so it covers the buttons below and goes off of the edge of the screen to the right. How can I control that grid so that the edges stay where they should in relation to the size of the screen? I’ve played with the anchor part of the layout, but it doesn’t seem to change anything.
// **************************************************
// Custom code for WorkQueueForm
// Created: 5/23/2016 11:46:30 AM
// **************************************************
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Erp.UI;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
using Ice.UI.FormFunctions;
using Infragistics.Win;
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 **
string strJob;
EpiUltraGrid MyGrid;
EpiTextBox JobFilter;
public void InitializeCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
// Begin Wizard Added Variable Initialization
MyGrid = (Ice.Lib.Framework.EpiUltraGrid)csm.GetNativeControlReference("b3e2940f-c81e-4838-9d16-90eff26f2e04");
MyGrid.DisplayLayout.Override.AllowRowFiltering = DefaultableBoolean.True;
JobFilter = (Ice.Lib.Framework.EpiTextBox)csm.GetNativeControlReference("656e3909-9ed0-43b1-8b26-2f779051b6d0");
// End Wizard Added Variable Initialization
// Begin Wizard Added Custom Method Calls
this.JobFilterTextBox.Leave += new System.EventHandler(this.JobFilterTextBox_Leave);
// 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.JobFilterTextBox.Leave -= new System.EventHandler(this.JobFilterTextBox_Leave);
// End Wizard Added Object Disposal
// Begin Custom Code Disposal
// End Custom Code Disposal
}
private void JobFilterTextBox_Leave(object sender, System.EventArgs args)
{
// ** Argument Properties and Uses **
// args.Row["FieldName"]
// args.Column, args.ProposedValue, args.Row
// Add Event Handler Code
if (JobFilter.Text != "")
{
MyGrid.Rows.ColumnFilters["JobNum"].FilterConditions.Clear();
string strJob = JobFilter.Value.ToString();
MyGrid.Rows.ColumnFilters["JobNum"].FilterConditions.Add( FilterComparisionOperator.StartsWith, strJob );
}
else
{
MyGrid.Rows.ColumnFilters["JobNum"].FilterConditions.Clear();
}
}
}