Efficiently Adding Column to DataGrid

Used this today on the TFOrder Receipt form…Thanks a lot Jose.

2 Likes

John - did you figure out the syntax for the >= date for published column?

I never could, I ended up just building a dashboard using a smaller set of fields and a lot of parameters hard-coded since they didn’t apply in our environment. Good Luck!

You can count me as another community member grateful to Jose for posting this!

@josecgomez would you happen to have an example of subscribing to multiple fields? every time I try to add another field (I actually want to publish and subscribe to 3 fields from the BAQ) I get a error when loading the custom (even though the code compiles correctly every time)

I don’t have any code handy but you just do the subscribe again. Same code

//Once
string pubBinding = "POTotal.BuyerID";
		IPublisher pub = oTrans.GetPublisher(pubBinding);
		if(pub==null)
		{
			oTrans.PublishColumnChange(pubBinding, "MyCustomPublish");
			pub = oTrans.GetPublisher(pubBinding);
		}

		if(pub !=null)
			baqViewLate.SubscribeToPublisher(pub.PublishName, "POHeader_BuyerID");
	}
//again but change the field
string pubBinding2 = "POTotal.BuyerIDOtherField";
		IPublisher pub2 = oTrans.GetPublisher(pubBinding2);
		if(pub2==null)
		{
			oTrans.PublishColumnChange(pubBinding2, "MyCustomPublish2");
			pub2 = oTrans.GetPublisher(pubBinding2);
		}

		if(pub2 !=null)
			baqViewLate.SubscribeToPublisher(pub2.PublishName, "POHeader_BuyerIDOtherField");
	}

Ok thanks @josecgomez - That was how I did it (was getting a load error as I forgot to change the 2nd published field, so it was trying to do it twice), but as soon as I add that second field to subscribe to, my grid goes blank and returns nothing…with 1 field it works, but with 2 it gives me nothing…strange…I’ll keep trying

Thanks!

By chance are the pub/sub fields the same key in both views? I had issues when I tried to sync a UDx and UDxA on the same key name (ie. pub table 1 = UDx.Key sub table 2 = UDx.Key). I ended up using SetParentView i think to get around it.

post your function. might help to have another set of eyes on the code.

@josecgomez can we pass static param to baq with this?

Hey @Chris_Conn, they are not looking at the same field. When I publish just the PartNum field, it works, and my grid shows ALL of the parts with that criteria. I want to add JobNum and ASM so that it only brings back the record that I am looking for but as soon as I add the second (haven’t even tried to do three yet) the grid just goes blank.

As @knash suggested I will post what I have and hopefully be able to tell me where I am going wrong!

Here is what I used in the past to make this works.

public void CreateLateBAQView()
    	{
    		JobTrackerViewLate = new BAQDataView("ETK_JobTrackerMatNoPar");
    		oTrans.Add("LateOpenJobMatBAQ",JobTrackerViewLate);

    		string pubBinding = "JobHead.JobNum";
    		IPublisher pub = oTrans.GetPublisher(pubBinding);
    		if(pub==null)
    		{
    			oTrans.PublishColumnChange(pubBinding, "MyCustomPublish");
    			pub = oTrans.GetPublisher(pubBinding);
    		}

    		if(pub !=null)
    			JobTrackerViewLate.SubscribeToPublisher(pub.PublishName, "JobMtl_JobNum");

    		
    		pubBinding = "CurrAsm.AssemblySeq";
    		IPublisher pub2 = oTrans.GetPublisher(pubBinding);
    		if(pub2==null)
    		{
    			oTrans.PublishColumnChange(pubBinding, "MyCustomPublish2");
    			pub2 = oTrans.GetPublisher(pubBinding);
    		}

    		if(pub2 !=null)
    			JobTrackerViewLate.SubscribeToPublisher(pub2.PublishName, "JobMtl_AssemblySeq");
    	}

I think @surendrapal has me on the right path (was nice enough to skype me and walk me through a few things) - Will update shortly!

As always, very much appreciate everyone’s time!!

Hi @josecgomez and @tkoch ,

I am trying to replace the gridview in Method Tracker’s Material->List section.

This is my code:

// **************************************************
// Custom code for BOMTrackerForm
// Created: 2021-11-18 6:20:47 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;

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.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 **
		BAQDataView baqViewMT;

	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

		CreatMTtable();
	}


		public void CreatMTtable()
	{
		baqViewMT = new BAQDataView("ACSL_MethodTracker");

		oTrans.Add("ACSL_MethodTrackerBAQ",baqViewMT);


		string pubBinding1 = "PartRev.RevisionNum";
		string pubBinding2 = "PartMtl.MtlSeq";

		IPublisher pub1 = oTrans.GetPublisher(pubBinding1);
		IPublisher pub2 = oTrans.GetPublisher(pubBinding2);		

		


		if(pub1==null)
		{
		oTrans.PublishColumnChange(pubBinding1, "MyCustomPublish1");
		pub1 = oTrans.GetPublisher(pubBinding1);
		}

		if(pub1!=null)
		{
			baqViewMT.SubscribeToPublisher(pub1.PublishName,"PartRev_PartNum");
		}



		if(pub2==null)
		{
		oTrans.PublishColumnChange(pubBinding2, "MyCustomPublish2");
		pub2 = oTrans.GetPublisher(pubBinding2);
		}

		if(pub2!=null)
		{
			baqViewMT.SubscribeToPublisher(pub2.PublishName,"PartMtl_MtlSeq");
		}
		
	}
	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
	}
}








Compilation is successful:

I get this error when I load the form:
image

Would you be able to advise?

Many thanks in advance

Looks like whatever it is you’re replacing you’re breaking native dependent code. Are you binding your new view to the original grid? If so that could be the issue.

Have you been able to get this to work.

Looks like you have column that isn’t correct.

string pubBinding1 = “PartRev.RevisionNum”;

baqViewMT.SubscribeToPublisher(pub1.PublishName,“PartRev_PartNum”);

PartNum?? for both or RevisionNum.

		string pubBinding1 = "PartRev.RevisionNum";
		string pubBinding2 = "PartMtl.MtlSeq";

		IPublisher pub1 = oTrans.GetPublisher(pubBinding1);
		IPublisher pub2 = oTrans.GetPublisher(pubBinding2);		

		


		if(pub1==null)
		{
		oTrans.PublishColumnChange(pubBinding1, "MyCustomPublish1");
		pub1 = oTrans.GetPublisher(pubBinding1);
		}

		if(pub1!=null)
		{
			baqViewMT.SubscribeToPublisher(pub1.PublishName,"PartRev_PartNum");
		}