BAQ Data View

I have created a BAQ Data View that I would like to be able to subscribe to a text box in my Dashboard. This is just a free form text box that when a customer ID is entered into it the BAQ Data View will subscribe to it and reset the DataView. @josecgomez helped me with the Data View.

		//Customer - Customer Data View
private void CreateCustomerBAQView() 
	{
	GS_Customer_DataView = new BAQDataView("GS_Customer_DataView");
	oTrans.Add("GS_Customer_DataView", GS_Customer_DataView);
	var CustID = tbCustomerIDRef.Text.ToString();                   //This is where I need it to subscribe to text box - this doesn't seem to work. 
	oTrans.PublishColumnChange(CustID, Guid.NewGuid().ToString());
	var CustIDPub = oTrans.GetPublisher(CustID);
	GS_Customer_DataView.SubscribeToPublisher(CustIDPub.PublishName, "Customer_CustID");
	}	 

So to do that you’ll have to create a DataView and bind that to your TextBox. Try this

DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("CustID",typeof(string));
dt.Columns.Add(new DataColumn("SysRowID",typeof(Guid));
var r = dt.NewRow();
dt.Rows.Add(r);
EpiDataView edvMyCustomDV = new EpiDataView();
edvMyCustomDV.dataView = dt.DefaultView;
oTrans.Add("MyCustomView",edvMyCustomDV);

Once this runs for the first time (in initilize custom code) you should have a new data view in your dashboard called MyCustomView which you can bind to your TextBox. Then you can use the Publish Subscribe code above to publish changes tol your new cust ID field as

var CustID = "MyCustomView.CustID";                   //This is where I need it to subscribe to text box - this doesn't seem to work.
1 Like
		//Customer - Customer Data View
private void CreateCustomerBAQView() 
	{
	GS_Customer_DataView = new BAQDataView("GS_Customer_DataView");
	oTrans.Add("GS_Customer_DataView", GS_Customer_DataView);
	var CustID = "MyCustomView.CustID";
	oTrans.PublishColumnChange(CustID, Guid.NewGuid().ToString());
	var CustIDPub = oTrans.GetPublisher(CustID);
	GS_Customer_DataView.SubscribeToPublisher(CustIDPub.PublishName, "Customer_CustID");
	}	

//Customer - Make DataView for Publishing
	private void CustomerPublisherView()
	{
	DataTable dt = new DataTable();
	dt.Columns.Add(new DataColumn("CustID",typeof(string)));
	dt.Columns.Add(new DataColumn("SysRowID",typeof(Guid)));
	var r = dt.NewRow();
	dt.Rows.Add(r);
	EpiDataView edvMyCustomDV = new EpiDataView();
	edvMyCustomDV.dataView = dt.DefaultView;
	oTrans.Add("MyCustomView",edvMyCustomDV);
	}
		
//Customer - Refresh Data View
	private void RefreshCustomerDataView()
	{
		MethodInfo mi = GS_Customer_DataView.GetType().GetMethod("invokeExecute", BindingFlags.Instance | BindingFlags.NonPublic);
		mi.Invoke(GS_Customer_DataView, new object[]{ true });
	}
	
	//Customer - On Leave Refreshes the View and Grids
	private void tbCustomerIDRef_Leave(object sender, System.EventArgs args)
		{
		if (tbCustomerIDRef.Text.Length >= 3)
		{
			RefreshCustomerDataView();
		}
			else
			{
			}
		}
1 Like

Okay something isn’t right. The Data View is showing up. I bound the text box to the new data view. Then when I enter a valid customer number and leave the box I have it setup to reset the data view. It is resetting the data view but it is just finding the first record and not the matching record in the BAQ Data View.

Are you adding the new view before your BAQ View? (Order matters)
By the way you shouldn’t have to force it to refresh the publish / subscribe should take care of that for you

It is in the correct order now and working perfectly. I also removed the on leave refresh and that is working perfectly! Thank you so much as always. I really like these BAQ Data View’s vs. using a Dashboard, they seem so much faster and elegant!

2 Likes

Okay one more question. I have a search which populates this text box with a Customer ID. How can I get the view to refresh without the user having to tab out of the box

How are you invoking the search? Button Click? If so populate teh DataView not the TextBox.

myCustomDV.dataView[myCustomDV.Row].BeginEdit();
myCustomDV.dataView[myCustomDV.Row]["CustID"]=YourSearchResults
myCustomDV.dataView[myCustomDV.Row].EndEdit();

I am invoking the search with a button click.

Okay I put that in my Search Adapter Section:

	private void SearchOnCustomerAdapterShowDialog_1()
	{
		 //Wizard Generated Search Method
		 //You will need to call this method from another method in custom code
		 //For example, [Form]_Load or [Button]_Click

		bool recSelected;
		string whereClause = string.Empty;
		System.Data.DataSet dsCustomerAdapter = Ice.UI.FormFunctions.SearchFunctions.listLookup(this.oTrans, "CustomerAdapter", out recSelected, true, whereClause);
		if (recSelected)
		{
			System.Data.DataRow adapterRow = dsCustomerAdapter.Tables[0].Rows[0];
			tbCustomerIDRef.Text = adapterRow["CustID"].ToString();
			myCustomDV.dataView[myCustomDV.Row].BeginEdit();
			myCustomDV.dataView[myCustomDV.Row]["CustID"]=tbCustomerIDRef.Text;
			myCustomDV.dataView[myCustomDV.Row].EndEdit();
			changecustomernumber();			
		}
	}

I get the error the name “myCustomDV” does not exist in the current context.

Well sorry I’m not sure what the name of your custom DV try this

var myCustomDV = oTrans.Factory("MyCustomView");

then the rest of the code

Oh sorry, It was the Data View you were helping me with earlier.

//Customer - Make DataView for Publishing
	private void CustomerPublisherView()
	{
	DataTable dt = new DataTable();
	dt.Columns.Add(new DataColumn("CustID",typeof(string)));
	dt.Columns.Add(new DataColumn("SysRowID",typeof(Guid)));
	var r = dt.NewRow();
	dt.Rows.Add(r);
	EpiDataView edvMyCustomDV = new EpiDataView();
	edvMyCustomDV.dataView = dt.DefaultView;
	oTrans.Add("MyCustomView",edvMyCustomDV);
	}```

Right try the option above

Perfect! That worked Thank you!

Any thoughts on why an updatable dashboard that I am having subscribe to the Order Data View wouldn’t be working? It doesn’t respond when I enter an order number?