I have a common function that I would like to apply to every EpiCombo box on my form - preferably just on one sheet or just custom EpiCombos. Whatever is easier. How can I write that into a EpiViewNotification event?
Something like:
foreach (var eachEpiCombo in SerialNumberForm.OnlyEpiCombos)
{
specialfunction(eachEpiCombo);
}
That post was definitely helpful, but I could not get my function to execute. I think it might be working, it’s probably something in the way I am calling my function. See anything obvious? I’m slightly beyond my comfort zone here… haha
private void edvUD38View_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
{
// ** Argument Properties and Uses **
// view.dataView[args.Row]["FieldName"]
// args.Row, args.Column, args.Sender, args.NotifyType
// NotifyType.Initialize, NotifyType.AddRow, NotifyType.DeleteRow, NotifyType.InitLastView, NotifyType.InitAndResetTreeNodes
if ((args.NotifyType == EpiTransaction.NotifyType.Initialize))
{
if ((args.Row > -1))
{
foreach(Control c in SerialNumberForm.Controls)
{
if (c.Name.StartsWith("Vcmb"))
{
removeListItemsUnavailable(c);
}
}
}
}
}
private void removeListItemsUnavailable(Control c)
{
// ** Place Event Handling Code Here **
EpiCombo cmbBox = (EpiCombo) c;
DataTable sourceTable = (cmbBox.DataSource as DataTable);
var rows = sourceTable.Rows;
DateTime rdisDate = (DateTime) edvUD38View.dataView[edvUD38View.Row]["Date03"];
int rowCount = rows.Count;
if (rowCount > 0)
{
for (var i = rowCount - 1; i >= 0; i--)
{
DataRow row = sourceTable.Rows[i];
DateTime createDate = Convert.ToDateTime(row["CreateDate"]);
if (createDate > rdisDate)
{
row.Delete();
}
}
sourceTable.AcceptChanges();
}
}
I think what you’re trying to do is to modify the dataview, not the control itself.
I think your first question was answered, which was how to iterate through form controls.
The second question is more domain specific, but what are you trying to do exactly? Perhaps there is a simpler way.
I agree. You answered my question. I did move on to a different one. I am using UserCodes to populate these drop downs but I want to limit the items in the list to only items whose CreateDate is earlier than another date on my dataview. I couldn’t do it with a filter (I think because the filters only work with strings).
I tried doing that… but I must not be entering the right syntax. I thought it was because it was a string array in the filter. But by all means straighten me out. I tried something like:
There are very very few I can count them with a single hand reasons why in an Epicor customization you should ever iterate over controls. The architecture of Epicor is such that each control is bound to a data view / data set and anything you need to do should be done to the data and not the control directly. Even the style of the control can be affected by the dataview properties.
Not saying it can’t be done this way, but it shouldn’t unless you have no other choice.
This is exactly the logic I thought should work… but I can’t get it to work. Just to be sure, after TransDate there is a comma and two apostrophes before the other bracket?
Maybe I’m losing my mind.
The RDIS Date is bound to UD38View.Date03.
Here I am looking at the Columns.
That’s why I resorted to trying to iterate through the controls… Because it seemed better than making a BeforeDropDown event for 27 EpiCombos… lol. All because I can’t get this filter to work like it evidently works. Perhaps it’s a 10.2.300 bug?
Are the combos bound to UD38 also? I think the filter uses the field name and looks for the value in the same view, so if they are different views it might not work.
I don’t remember if you could use multi view columns in the filter, maybe, I can look later and see if I find any examples.
I don’t get an error. When I did the trace, I did not find any reference to UserCodes like you have shown. I’m sure that must be part of my problem.