I’ve used EpiCombos cool little adapter search feature for a while now. It’s really handy and exceptionally so for UserCodes by just filtering the specific code type you want. I’ve ran into an issue that wanted to see if anyone has dealt with before.
In my current project I have a multipurpose field tied to various lookups. When I load a group of records, my custom field has various value types. The problem is, for invalid codes on other types, it still shows the items in the dropdown but with a (Code deleted) beside them. Before I started pouring over the decompiled EpiClient lib I wanted to see if anyone had some suggestions
First thought as the easiest approach is to catch BeforeDropDown and delete those items but I’d prefer a more sane solution.
I wasnt aware that was a thing. I’ll give it a try later. Thanks. At first glance, I dont think it will work, because the issue is not that the codes are inactive, they simply dont exist.
Imagine 3 different combos pointed to 3 different user code types. All are saved\EpiBound to same field in a table. So there will be records within that field that do not exist in the UserCodes, i do not want these showing up in the dropdown.
If Field1 = “Dog”, Field2 dropdown contains Dogs.
If Field2 = “Cat”, Field2 dropdown contains Cats.
What happens is, when a list of records is loaded, for the values that do not exist in the User Codes, they show up with (Code deleted) beside them. As I mentioned, my code above solves the issue at hand.
hummm, i found this code example on the Stack website, no idea if you can use it in your case, but i imagine you need to put all of your possible -created on the UI Customization- values in a separate list (array), then apply this
@Chris_Conn - I tried to use this and it works, but only after I clear two errors when clicking the drop-down arrow… incidentally, there are 2 items getting filtered out of the list. Is there a bit somewhere else I need to add to make it happy?
This is a big ask… but when I use your version, it doesn’t delete the rows. I must be overlooking something. No errors. But you can see those choices are still there in the list.
private void cmbVehicleType_BeforeDropDown(object sender, System.ComponentModel.CancelEventArgs args)
{
// ** Place Event Handling Code Here **
DataTable sourceTable = (cmbVehicleType.DataSource as DataTable);
var rows = sourceTable.Rows;
DateTime rdisDate = (DateTime) edvUD38View.dataView[edvUD38View.Row]["Date03"];
int rowCount = rows.Count;
/*
foreach (DataRow eachRow in rows)
{
DateTime createDate = Convert.ToDateTime(eachRow["CreateDate"]);
if (createDate > rdisDate)
{
eachRow.Delete();
}
}
sourceTable.AcceptChanges();
*/
if (rowCount > 1) return;
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 can’t express the level of facepalm that I am experiencing right now. I spent the better part of my afternoon yesterday trying all sorts of other things all because I started out with it wrong…
Thank you for pointing that out. I must’ve compared the two 15 times and never saw that error.