Adding multiple columns to existing gridviews

Hi Epicor Community,

I am trying to add multiple columns to gridview of Method Tracker.
In doing so, I tried following this topic :

My purpose is to add some attributes from Part Table that do not exist in the Collection list.
Here is the code that I wrote and runs with no problem while loading the data but clearly I am doing something wrong:

// **************************************************
// Custom code for BOMTrackerForm
// Created: 2021-11-17 1:12:58 PM
// **************************************************

extern alias Erp_Contracts_BO_EngWorkBench;
extern alias Erp_Contracts_BO_ECORevSearch;
extern alias Erp_Contracts_BO_BomSearch;
extern alias Erp_Contracts_BO_Part;
extern alias Erp_Contracts_BO_PartRevSearch;
extern alias Erp_Contracts_BO_Customer;
extern alias Ice_Contracts_Lib_BOReader;

using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Erp.Adapters;
using Erp.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 Ice.Proxy.Lib;
using Ice.Core;
using Erp.BO;
using Ice.BO;

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

    EpiUltraGrid myGrid;
	BOReaderImpl _boReader; 

	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

		myGrid = (EpiUltraGrid)csm.GetNativeControlReference("74efd6bb-a282-4bc2-bcd4-135633814caa");
		//myGrid.DisplayLayout.Bands[0].Columns.Add("PartType","Job Released");
		myGrid.DisplayLayout.Bands[0].Columns.Add("Part Type","Company222");
		myGrid.InitializeRow += new Infragistics.Win.UltraWinGrid.InitializeRowEventHandler(grdMatLst_InitializeRow);
		_boReader = WCFServiceSupport.CreateImpl<BOReaderImpl>((Ice.Core.Session)oTrans.Session, Epicor.ServiceModel.Channels.ImplBase<Ice.Contracts.BOReaderSvcContract>.UriPath);
	}

	private void grdMatLst_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
	{
		if(!String.IsNullOrEmpty(e.Row.Cells["PartNum"].Value.ToString()))
		{
			//DataSet ds = _boReader.GetRows("Erp:BO:PartEntry","PartNum = '" + e.Row.Cells["PartNum"].Value.ToString() + "'","JobReleased");
			DataSet ds = _boReader.GetRows("Erp:BO:PartEntry","PartNum = '" + e.Row.Cells["PartNum"].Value.ToString() + "'","RevisionNum");
			if(ds.Tables[0].Rows.Count > 0 ) 
			{
				//e.Row.Cells["JobReleased"].Value = ds.Tables[0].Rows[0]["JobReleased"].ToString();
				e.Row.Cells["TypeCode"].Value = ds.Tables[0].Rows[0]["TypeCode"].ToString();
			}
		}
	}


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









Could you kindly guide me?
I see two problems:

1- As you can see in the code, the Company2222 is added to the columns which I used for my reference, however Part Type did not get added.

2- Company2222 does not load any data and when I click on it (notice the difference in color of its column) and type something, I get this:


Please notice that I am not trying to enter any data so I am confused why this field is fallible now as well.

Many thanks in advance

Regards,
Shizar

I made a few mistakes.
Apologies if that caused confusion. I figured these:

1-

myGrid.DisplayLayout.Bands[0].Columns.Add("Part Type","Company222");

should be changed to:

myGrid.DisplayLayout.Bands[0].Columns.Add("TypeCode","Part Type");

2-

DataSet ds = _boReader.GetRows("Erp:BO:PartEntry","PartNum = '" + e.Row.Cells["PartNum"].Value.ToString() + "'","RevisionNum");

Should be changed to:

DataSet ds = _boReader.GetRows("Erp:BO:Part","PartNum = '" + e.Row.Cells["PartNum"].Value.ToString() + "'","RevisionNum");

After these changes, I still get the white-background column. The error this time has changed to this:

Which does not make much sense. TypeCode is indeed a column in Part table…

Finally it is done and completed:

// **************************************************
// Custom code for BOMTrackerForm
// Created: 2021-11-17 1:12:58 PM
// **************************************************

extern alias Erp_Contracts_BO_EngWorkBench;
extern alias Erp_Contracts_BO_ECORevSearch;
extern alias Erp_Contracts_BO_BomSearch;
extern alias Erp_Contracts_BO_Part;
extern alias Erp_Contracts_BO_PartRevSearch;
extern alias Erp_Contracts_BO_Customer;
extern alias Ice_Contracts_Lib_BOReader;


using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Erp.Adapters;
using Erp.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 Ice.Proxy.Lib;
using Ice.Core;
using Erp.BO;
using Ice.BO;

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

    EpiUltraGrid myGrid;
	BOReaderImpl _boReader; 

	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

		myGrid = (EpiUltraGrid)csm.GetNativeControlReference("74efd6bb-a282-4bc2-bcd4-135633814caa");
		//myGrid.DisplayLayout.Bands[0].Columns.Add("PartType","Job Released");
		myGrid.DisplayLayout.Bands[0].Columns.Add("TypeCode","Part Type");
		myGrid.InitializeRow += new Infragistics.Win.UltraWinGrid.InitializeRowEventHandler(grdMatLst_InitializeRow);
		_boReader = WCFServiceSupport.CreateImpl<BOReaderImpl>((Ice.Core.Session)oTrans.Session, Epicor.ServiceModel.Channels.ImplBase<Ice.Contracts.BOReaderSvcContract>.UriPath);
	}

	private void grdMatLst_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
	{
		if(!String.IsNullOrEmpty(e.Row.Cells["PartNum"].Value.ToString()))
		{
			//DataSet ds = _boReader.GetRows("Erp:BO:PartEntry","PartNum = '" + e.Row.Cells["PartNum"].Value.ToString() + "'","JobReleased");
			DataSet ds = _boReader.GetRows("Erp:BO:Part","PartNum = '" + e.Row.Cells["MtlPartNum"].Value.ToString() + "'","TypeCode");
			if(ds.Tables[0].Rows.Count > 0 ) 
			{
				//e.Row.Cells["JobReleased"].Value = ds.Tables[0].Rows[0]["JobReleased"].ToString();
				e.Row.Cells["TypeCode"].Value = ds.Tables[0].Rows[0]["TypeCode"].ToString();
			}
		}
	}


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


















2 Likes