Add Fields to Epicor Custom Grid

you are using GetList, would GetRows to grid could make a different ?

Good call, let me try that

Still similar results

then based on this, the second step which is inserting back the data to existed grid row by row is the bottleneck as DQ will display the whole data in one hit !! am i right ?

Yes, I think it is slow because it runs for each row in the grid. I have done in the past if I know I need data like this I just pull all the data in one call to a dataset (just query for Resource table on form load) then on row initialize find the relevant data in the dataset rather than running a query for each row

1 Like

sharing your example here will be priceless :grin:

I’ll have to locate it, been awhile

This is an example of me hijacking the grid on Part Trans History Tracker and adding columns using BAQDataView. Made it run much quicker than per grid row queries

// **************************************************
// Custom code for PartTranHistForm
// Created: 5/28/2015 5:19:45 PM
// **************************************************

extern alias Erp_Contracts_BO_Part;
extern alias Erp_Contracts_BO_PartPlantSearch;

using System;
//using System.Linq;
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 Epicor.ServiceModel.Channels;
using Ice.Proxy.Lib;
using Ice.Core;
using System.Data.SqlClient;
using Ice.Lib.Broadcast;

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 **
	private EpiDataView edvTranJobInfo;
	private EpiUltraGrid dgv;
	private EpiButton btnRet;

	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
		dgv = (EpiUltraGrid)csm.GetNativeControlReference("f83d6262-a7d9-4fb5-a7d0-54644a9bb66b");
		btnRet = (EpiButton)csm.GetNativeControlReference("e0aaf31e-51a0-4692-8932-9ff0545e716e");
		btnRet.Click += btnRet_Click;

		CreateBAQView();		
	}

	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
		btnRet.Click -= btnRet_Click;
		btnRet = null;
		dgv = null;
		edvTranJobInfo = null;
		// End Custom Code Disposal
	}

	private void btnRet_Click(object sender, System.EventArgs e)
	{
				DataView dv = dgv.DataSource as DataView;
				if (!dv.Table.Columns.Contains("AsmSeq"))				
					dv.Table.Columns.Add("AsmSeq");
				
				if (!dv.Table.Columns.Contains("JobSeq"))				
					dv.Table.Columns.Add("JobSeq");
				
				if (!dv.Table.Columns.Contains("JobDesc"))
					dv.Table.Columns.Add("JobDesc");
				if (!dv.Table.Columns.Contains("EmpId"))
					dv.Table.Columns.Add("EmpId");
				if (!dv.Table.Columns.Contains("EmpName"))
					dv.Table.Columns.Add("EmpName");
				
				
				foreach (DataRow row in dv.Table.Rows)
				{
					foreach (DataRow row2 in edvTranJobInfo.dataView.Table.Rows)
					{
						if (row["TranNum"].ToString() == row2["PartTran_TranNum"].ToString())
						{
							row["AsmSeq"] = row2["PartTran_AssemblySeq"];
							row["JobSeq"] = row2["PartTran_JobSeq"];
							row["JobDesc"] = row2["JobHead_PartDescription"];
							row["EmpId"] = row2["EmpBasic_EmpId"];
							row["EmpName"] = row2["EmpBasic_Name"];
							break;
						}
					}
				}
		
				dgv.DataSource = dv;		
	}

	// this is needed to speed up loading of records
	private void CreateBAQView()
	{
		BAQDataView baqView = new BAQDataView("PartTranJobInfo");
		oTrans.Add("PartTranJobInfo", baqView);
		string pubBinding = "Part.PartNum";
		//string plantBinding = "PartTranHist.Plant";
		IPublisher pub = oTrans.GetPublisher(pubBinding);
		if (pub == null)
		{
			oTrans.PublishColumnChange(pubBinding, "PartNumPub");
			pub = oTrans.GetPublisher(pubBinding);	 
		}
		
		//subscribe to BAQView
		if (pub != null)
		{
			baqView.SubscribeToPublisher(pub.PublishName, "PartTran_PartNum");
		}

		edvTranJobInfo = (EpiDataView)oTrans.EpiDataViews["PartTranJobInfo"];
	}
}
1 Like

many thanks mate, really appreciate this, have a very nice evening