Clear button won't clear grid after adding column into it

Hey everyone,

I am adding two columns into Invoice Entry main grid which causes the grid not to clear when user clicks on the Clear icon (Broom). I tried to clear it programmatically inside AfterAdapter method for case “ClearData” or case “ClearList”, none of them works as they even prevent the form from loading.

I add columns using a similar code like this:

Ice.Lib.Framework.EpiUltraGrid ctrl = (Ice.Lib.Framework.EpiUltraGrid)csm.GetNativeControlReference(“fe13awbf-c0sd-4ae4-ad55-ece043bcf3ce”);
DataTable dt = ((DataView)ctrl.DataSource).ToTable();
if (!dt.Columns.Contains(“CPF”))
{
DataColumn newCol = dt.Columns.Add(“CPF”, typeof(string));
newCol.SetOrdinal(0);
newCol = dt.Columns.Add(“Freight”, typeof(decimal));
newCol.SetOrdinal(1);
ctrl.DataSource = dt.DefaultView;
}
Then I populate those columns. All works fine except the clear button.

Thanks! Stay safe everyone!

I believe your issue is that you are breaking the EpiMagic.

By manually setting a DataSet instead using a custom EDV (which you can create to load that dt.DefaultView) and setting the EpiBinding, the oTrans has no clue what to do.

///In Initialize
//create a new EpiDataView
EpiDataView edvCustom = new EpiDataView();

//define it as dt.DefaultView;
edvCustom.dataView = dt.DefaultView;

//add it it to oTrans
oTrans.Add(“MyCustomEDV”,edvCustom);

//set the Epibinding on ctr to MyCustomEDV
after a restart of the form

2 Likes

Hey Chris,

Thanks! I definitely needed to get some rest before implementing this lol I was having a completely wrong approach! Duh!

All I had to do was to add the columns into the edvDataView on InitializeCustomCode as so:

if(!edvInvcHeadList.dataView.Table.Columns.Contains(“CPF”))
{
edvInvcHeadList.dataView.Table.Columns.Add(“CPF”,typeof(string));
}
if(!edvInvcHeadList.dataView.Table.Columns.Contains(“Freight”))
{
edvInvcHeadList.dataView.Table.Columns.Add(“Freight”,typeof(decimal));
}

And to populate them after (In a loop):

edvInvcHeadList.dataView.Table.Rows[itr][“CPF”] = …

Thanks a lot for the hint!