Efficiently Adding Column to DataGrid

What is the most efficient way to add a new column to a datagrid? In the past I have added the column and then on the InitializeRow event used the BOReader to retrieve the data, obviously if the grid has a lot of rows this slows down the application significantly.

I don’t know if there is a better method for doing this or if anyone has suggestions.

Thanks,

Ted

Your best and most efficient way is a BAQ view. Write a BAQ that shows the data you need and then publish subscribe the BAQ view and bind the grid to it.
If you tell me which screen / grid I may be able to provide a better example

Hi Jose,

I have added a custom (date) field to the PO Release tab, that purchasing would like to see in the Buyer Workbench under PO’s -> Open PO’s -> Late, Today, This Week, Future.

I have done something similar for the Part Transaction History Tracker in the past, but that form displays one part number at a time. This workbench is for multiple PO’s, not sure how a BAQView would handle that to populate multiple rows.

Well if there is no Part to Pivot off or anything like that you can just have the BAQ View stand on its own. I think it just tied to the “current” buyer? Either way you can just have a BAQ view driven off the current buyer and replace it with a BAQ View which has your custom field in it.

Here’s a quick example that does what you want ( and a brief video explaining how it works if ya wanna know)

	//Using 
	using Ice.Lib.Broadcast;
	//Class Level 

	BAQDataView baqViewLate;
	public void CreateLateBAQView()
	{
		baqViewLate = new BAQDataView("LateOpenPos");
		oTrans.Add("LateOpenPOBAQ",baqViewLate);

		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");
	}

28 Likes

Thank you Jose. I will give this a go.

Jose,

Can you share the BAQ you used for this?

I’m guessing the criteria you used was PromiseDate < Today?

I don’t have it anymore it was an education DB so I replaced it, but yeah it was just PromiseDate < Today and then for adding 30 etc you can use the Date + X function in the BAQ

I got this working. Also, the PO Entry button on the form was not working because it is looking for a different EpiDataView. I added a new button with this code to get it to work. The only this that doesn’t work is when the refresh button is clicked on the form the grid doesn’t refresh the data. Anyone know how to refresh a BAQDataView? I’ve tried Notify and OnSearch methods, but didn’t work.

string view = mainDock.poDock1.openPOsPanel1.openPODock1.EpiSelectedSheet;
    string epiBinding = "";
    if (view == null)
    {
        view = "poLate";
    }
    int num = 0;
    if (view == "poLate")
    {
        epiBinding = "POLate.PONum";
        if (baqViewLate.dataView.Count > 0)
        {
            num = int.Parse(baqViewLate.dataView[baqViewLate.Row]["PORel_PONum"].ToString());
        }
    }
    else if (view == "poToday")
    {
        epiBinding = "POToday.PONum";
        if (baqViewToday.dataView.Count > 0)
        {
            num = int.Parse(baqViewToday.dataView[baqViewToday.Row]["PORel_PONum"].ToString());
        }
    }
    else if (view == "poThisWeek")
    {
        epiBinding = "POThisWeek.PONum";
        if (baqViewThisWeek.dataView.Count > 0)
        {
            num = int.Parse(baqViewThisWeek.dataView[baqViewThisWeek.Row]["PORel_PONum"].ToString());
        }
    }
    else if (view == "poFuture")
    {
        epiBinding = "POFuture.PONum";
        if (baqViewFuture.dataView.Count > 0)
        {
            num = int.Parse(baqViewFuture.dataView[baqViewFuture.Row]["PORel_PONum"].ToString());
        }
    }
    if (num != 0)
    {
        LaunchFormOptions launchObject = new LaunchFormOptions {
            PublisherKey = oTrans.GetPublisher(epiBinding).PublishKey,
            ValueIn = num
        };
        ProcessCaller.LaunchForm(oTrans, "PMGO2001", launchObject);
    }
    else
    {
        ProcessCaller.LaunchForm(oTrans, "PMGO2001");
    }

I had successfully implemented your codes? Thanks for sharing best article. I was trying to extends this process in C# with more than one publisher and subscriber. We may publish more than one publisher and subscribe them in dashboard building.
How can we pass more than one publisher using ?
string pubBinding = “POTotal.BuyerID”;
IPublisher pub = oTrans.GetPublisher(pubBinding);

How can we consume this published values like your code?
baqViewLate.SubscribeToPublisher(pub.PublishName, “POHeader_BuyerID”);

Appreciated your support.
Thanks,
Mukesh Desai

I’m not 100% sure, but you can probably call SubscribeToPublisher multiple times to subscribe to multiple publishers. You would have to try that.

@josecgomez That is a great explanation, thanks!

Mukesh, were you ever able to make this work using more then one publish and subscribe value? We are trying to replace a grid in quote entry at the material line level and need to filter the Quote Number, Line Number and assembly number but have not been able to make it work

Regards,

Do do more than one publish subscribe just add additional publish and subscribe columns

The same thing I do just add additional Publishers and additinoal Subscribe to publisher commands.

I haven’t got opportunity for testing. But reading from form and per Jose suggestion, its possible.

This was very helpful! Thanks, Jose.

We have a few versions of our CustomerEntryForm. I replaced an embedded dashboard with this on the first version and it worked as expected every time.

I’m now apply the fix to our other customer entry screens and have run into a problem. I am using Customer.CustNum as the publisher. The first customer retrieved doesn’t filter the BAQ as expected. Not when I type a customer ID and tab, nor when I use the button to search. The next customer and customers after that filter the BAQ as expected.

What could I be doing prevent this from working on the first retrieve?

Can you add CustID to your BAQ and filter on that? I wonder if the CustNum doesn’t get populated right away?

Great idea. I did try, but no luck. I did stumble across the reason though. I had version 1 of the CustomerEntryForm open so I could copy code from it. I use shift-click all the time to open a second instance of the same screen. In this case I did that and opened version 2 to paste into. I then shift-clicked to open version 2 in run-time mode and saw the problems.

If I only have one instance of the screen open (not even the customization tools open) the code runs as I expect.

The converted customization was a static class, so I am using a static BAQDataView member and static method to set it up. Since I am copying and pasting the same names, is it the fact that they are static that is causing the issue?

Yeah potentially…

What would the syntax be for a >= date? For example, in Part Tran History Tracker there is a Starting Date and Cutoff Date, I have them both published but it only shows transactions where the date’s are equal. Thanks,