This code compiles ok. But my grids don’t get populated with any data.
public class Script
{
public BAQCombo cmbpartrev;
DataTable dtPartRevOps;
EpiDataView dvPartRevOps;
DataTable dtEcoRevOps;
EpiDataView dvEcoRevOps;
BAQDataView bdvEco, bdvPart;
DataTable dtRevOps;
EpiDataView dvRevOps;
// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
// Begin Wizard Added Module Level Variables **
private EpiDataView edvPartRevOps;
private EpiDataView edvEcoRevOps;
// End Wizard Added Module Level Variables **
// Add Custom Module Level Variables Here **
public void InitializeCustomCode()
{
SetupBAQDvs();
// filtered out a bunch of lines here...
public void SetupBAQDvs()
{
//Create a EpiDataView to use for filtering
dtRevOps = new DataTable(); //instantiate DT
var colMyPart = new DataColumn("Part"); // inst column
colMyPart.ExtendedProperties["Like"]="Part.PartNum"; //add like for right click open with
dtRevOps.Columns.Add(colMyPart); // add custom column to DT (repeat for all columns)
var colMyRev = new DataColumn("Rev"); // inst column
dtRevOps.Columns.Add(colMyRev); // add custom column to DT (repeat for all columns)
dtRevOps.Columns.Add(new DataColumn("SysRowId",typeof(Guid))); // add guid column to DT (required)
var dr = dtRevOps.NewRow(); //inst a new row
dr["SysRowId"] = Guid.NewGuid(); // just set the guid for the new row
dtRevOps.Rows.Add(dr); // add the row to the DT to enable fields in the table
dvRevOps = new EpiDataView(); //inst the EDV
dvRevOps.dataView = dtRevOps.DefaultView; // set the EDV to the default view of the DT created above (default view is unfiltered view of entire DT)
oTrans.Add("OpsList",dvRevOps); // adds the EDV to the binding list
//Publish Changes to Part and Rev columns
var fromPubPart= "OpsList.Part"; //whenever the listed field changes publish the new value
oTrans.PublishColumnChange(fromPubPart,"FromPubPart"); //publish the value to otrans
var fromPub = oTrans.GetPublisher(fromPubPart); //this pulisher 'fromPub' gets the notification when above field changes.
var fromPubRev= "OpsList.Rev"; //whenever the listed field changes publish the new value
oTrans.PublishColumnChange(fromPubRev,"FromPubRev"); //publish the value to otrans
var fromPub2 = oTrans.GetPublisher(fromPubRev); //this pulisher 'fromPub' gets the notification when above field changes.
//Setup the first BAQDataView
bdvEco = new BAQDataView("getPartRevOpECO"); //inst the BDV
oTrans.Add("EcoRevOps",bdvEco); //add the BDV to the binding list (this is an unfiltered BDV. Filter the BDV with Pub/Sub)
bdvEco.SubscribeToPublisher(fromPub.PublishName,"ECORev_PartNum"); // subscribe BDV to fromPub created above. filer by listed field based on publisher.
bdvEco.SubscribeToPublisher(fromPub2.PublishName,"ECORev_RevisionNum"); // subscribe BDV to fromPub created above. filer by listed field based on publisher.
//Setup the Second BAQDataView
bdvPart = new BAQDataView("EditAnyOp"); //inst the BDV
oTrans.Add("PartRevOps",bdvPart); //add the BDV to the binding list (this is an unfiltered BDV. Filter the BDV with Pub/Sub)
bdvPart.SubscribeToPublisher(fromPub.PublishName,"PartRev_PartNum"); // subscribe BDV to fromPub created above. filer by listed field based on publisher.
bdvPart.SubscribeToPublisher(fromPub2.PublishName,"PartRev_RevisionNum"); // subscribe BDV to fromPub created above. filer by listed field based on publisher.
}
// filtered some more lines out...
//the function below should populate and display the correct grid as needed. Currently only showing a blank grid.
private void CheckForCheckedOut()
{
oTrans.PushStatusText("Looking for checked out part/revs...", false);
if (bdvEco.dataView.Count > 0)
{ //Show ECORev
//MessageBox.Show("Checked Out!");
epiGridPartRev.Hide();
epiGridEcoRev.Show();
epiGridEcoRev.EpiBinding = "EcoRevOps";
epiGridEcoRev.Text = "This Revision is Checked-Out!";
epiGridEcoRev.Refresh();
EpiUltraGrid MyGridEcoRev = ( ( EpiUltraGrid )csm.GetNativeControlReference( "a6178e89-673d-42d8-bf20-879a3a242484" ) );
UltraGridBand bandEcoRevs = MyGridEcoRev.DisplayLayout.Bands[0];
bandEcoRevs.Columns[5].Width = 550;
//set the comment column to be wider
isCheckedOut.Show();
}
else //Show PartRev
{
//MessageBox.Show("Not Checked Out!");
epiGridEcoRev.Hide();
epiGridPartRev.Show();
epiGridPartRev.EpiBinding = "PartRevOps";
epiGridPartRev.Text = "This Revision is Not Checked-Out.";
epiGridPartRev.Refresh();
EpiUltraGrid MyGridPartRev = ( ( EpiUltraGrid )csm.GetNativeControlReference( "f19fb3e9-5c6b-4e2b-8d7e-f36c7a37a959" ) );
UltraGridBand bandPartRevs = MyGridPartRev.DisplayLayout.Bands[0];
bandPartRevs.Columns[5].Width = 550;
//set the comment column to be wider
isCheckedOut.Hide();
}
oTrans.PushStatusText("Done!", false);
}
