Add Fields to Epicor Custom Grid

Here is the updated code that will work. You could probably use GetList or GetRows for this. GetList would get you some better performance.

// **************************************************
// Custom code for ResourceSchedForm
// Created: 9/28/2018 8:47:46 AM
// **************************************************
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("87f88dc8-1b94-4324-ba83-583a2af5cbb9");
		myGrid.DisplayLayout.Bands[0].Columns.Add("JobReleased","Job Released");
		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["JobNum"].Value.ToString()))
		{
			DataSet ds = _boReader.GetRows("Erp:BO:JobEntry","JobNum = '" + e.Row.Cells["JobNum"].Value.ToString() + "'","JobReleased");
			if(ds.Tables[0].Rows.Count > 0 ) 
			{
				e.Row.Cells["JobReleased"].Value = ds.Tables[0].Rows[0]["JobReleased"].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
	}
}
4 Likes