How to refresh an EpiDataView that is loaded from a BAQ

Hi Team,
I mingled some code together which allows me to

  • create a sheet with an EpiUltraGrid in Order Entry as a “Power Search”
  • use an external baq to Epicor (for performance reasons)
  • pass the Query results to a DataView which is the grid source
  • Use the view to search for parts, show images and create the order lines in one go

It works great and even with 40k loaded parts far more performant than the traditional line creation/part search. For us as a distributor, performance is key and this seems to be fastest option
So far so good, now my challenge is how to refresh the data view without having to reopen the screen, mainly to refresh on hand qty…
I checked here and everywhere, no luck…

Summary: How can I trigger to run the BAQ again and refresh the existing data view.
Hope it’s just a simple DataView.ReloadWithBAQ command… I’m an Application Engineer, not a programmer as you can tell LOL

This is the code snippet I trigger on initate amd like to trigger again when clicking the Refresh Button:

	public void LoadPartView()
	{
		// create instance of DynamicQueryAdapter and Connect
		// Create instance of Adapter
		DynamicQueryAdapter _baqAdapter = new DynamicQueryAdapter(oTrans);
		_baqAdapter.BOConnect();
		_baqAdapter.ExecuteByID("AW_OrderPartSearchExt");
		_edvBAQParts = new EpiDataView();
		_edvBAQParts.dataView = new DataView(_baqAdapter.QueryResults.Tables["Results"]);

	// Make columns read-only
		foreach (DataColumn dc in _edvBAQParts.dataView.Table.Columns)
        {
        	//dc.ReadOnly = true;
			dc.ExtendedProperties["ReadOnly"] = true;
			dc.ExtendedProperties["Like"] = dc.ColumnName.ToString();
        }
        //_edvBAQParts.dataView.Table.Columns["OrderQty"].ReadOnly = false;
		// MessageBox.Show("8 " + _edvBAQParts.dataView.Table.Columns[0].ColumnName.ToString() );
		if (_edvBAQParts.dataView.Table.Columns.Contains("LSC_OrderPartSearch_OrderQty"))
			_edvBAQParts.dataView.Table.Columns["LSC_OrderPartSearch_OrderQty"].ExtendedProperties["ReadOnly"] = false;
	
		if ((oTrans.EpiDataViews.ContainsKey("BAQPartsView") == false))
		{
			oTrans.Add("BAQPartsView", _edvBAQParts);
		}
		else
		{
			// HERE I NEED SOME MAGIC TO REFRESH THE EXISTING VIEW...
			oTrans.Refresh();
		}
		_baqAdapter.Dispose();

I am not sure if this is the right way, but I use this bit of code to refresh BAQs in my customized dashboards.

// refresh all
void RefreshAllBAQs()
{
oTrans.PushStatusText("Refreshing all views. Please be patient...", false);      
MainController.AppControlPanel.HandleToolClick("RefreshAllTool", new 
Infragistics.Win.UltraWinToolbars.ToolClickEventArgs(MainController.MainToolManager.Tools["RefreshAllTool"], null)); 
oTrans.PushStatusText("Done!", false);
}

After rereading your request, I don’t think that is what you want. There is also this little bit of code that can requery your BAQ.

 // BAQ Execute (GetList) Method
private void RefreshBAQDataView(BAQDataView iBaqView)
{
MethodInfo mi = iBaqView.GetType().GetMethod("invokeExecute", BindingFlags.Instance | BindingFlags.NonPublic);
mi.Invoke(iBaqView, new object[]{ true });
}

Hope this helps get you started. Good Luck!
Nate

1 Like

Hi Nate,
Thanks for the reply, this will be useful for customized dashboards.
The problem I’m having is that I’m creating an EpiDataView and feed it with the results fro the BAQ, all done in an Order Entry Customization.
I can refresh existing data views that feed from the db, but not from a query. I’ll see if your second snipped helps, I tried Begin/End Edit as I had seen for updating particular columns, but that doen;t seem to work with the whole view…

		DynamicQueryAdapter _baqAdapter = new DynamicQueryAdapter(oTrans);
		_baqAdapter.BOConnect();
		_baqAdapter.ExecuteByID("AW_OrderPartSearchExt");

		EpiDataView _edvBAQParts = ((EpiDataView)(this.oTrans.EpiDataViews["BAQPartsView"]));
		//_updBAQParts = new EpiDataView();
		_edvBAQParts.dataView[0].BeginEdit();
		_edvBAQParts.dataView = new DataView(_baqAdapter.QueryResults.Tables["Results"]);
		_edvBAQParts.dataView[0].EndEdit();
		oTrans.Update();
		oTrans.Refresh();

Thanks again

@Wunschi

If you add one line to your code as below, I believe it will work:

if ((oTrans.EpiDataViews.ContainsKey("BAQPartsView") == false))
{
	oTrans.Add("BAQPartsView", _edvBAQParts);
}
else
{
	// HERE I NEED SOME MAGIC TO REFRESH THE EXISTING VIEW...
	oTrans.Refresh();
	epiUltraGridC1.DataSource = _edvBAQParts.dataView;
}

Where “epiUltraGridC1” is the name or reference to your EpiUltraGrid.

Hope this helps.

3 Likes

You legend Ibrahim,
I was so focused on refreshing the dataview, which apparently already occured, but not updating the grid.
Problem solved, thanks a lot!!!
Cheers
Andreas

2 Likes