Adding multiple columns to existing gridviews

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