I have following data in a lookup table.
I have an editable UltraGrid that allows users to select a category for each row, using a column having UltraComboEditor to display categories.
Users can only select categories that are not deleted i.e. Electronics and Smartphones. However, if the row already has a record that references deleted category (Personal care, Id=2), it should be added to the list of items in the UltraComboEditor
For all new rows, it UltraComboEditor should only contain non-deleted categories.
My Category column is similar to EmployeeID column in the following snapshot:
How can I accomplish that?
- Talha Anwer
In order to make sure that I understand your requirement correctly I have several questions:
Answering these questions is going to be highly appreciated.
Thank you for your cooperation.
Looking forward to hearing from you.
Associate Software Developer
I would like users to be able to keep/select deleted categories for existing rows, but once they have modified the existing record and selected a non-deleted category, they should not be able to go back to select the deleted category. For all new rows, user should not be able to selected a deleted category.
I have been looking into your requirement, however, since hiding or disabling items in UltraComoEditor is currently not provided out of the box I can suggest to modify the data that is bound to the list by adding or removing items from it depending on the grid's cell value. This could be done in the UltraGrid's BeforeCellListDropDown event that fires just before the drop-down for each cell is expanded. There we can remove all rows that have deleted value equals to true an in case the cell value is a category that is deleted we could add it to the data again.
private void ultraGrid1_BeforeCellListDropDown(object sender, Infragistics.Win.UltraWinGrid.CancelableCellEventArgs e)
var cellValue = e.Cell.Value;
for (int i = ((DataTable)ultraComboEditor1.DataSource).Rows.Count - 1; i >= 0; i--)
DataRow dr = ((DataTable)ultraComboEditor1.DataSource).Rows[i];
if (dr.ItemArray.ToString() == "True")
if (cellValue != null)
var row = getRowIfTrue(cellValue.ToString());
if(row != null)
((DataTable)ultraComboEditor1.DataSource).DefaultView.Sort = "ID desc";
Additionally, if you require to hide or disable the item, instead of modifying the data source, I can recommend using UltraCombo instead of UltraComboEditor. UltraCombo is like a WinGrid and the Rows within it can be disabled using the Activation property on the row or their hidden property could be changed.
I have attached a sample application, that uses the above approach.
Please test it on your side and let me know if I may be of any further assistance.
Removing the items from the data source is probabaly not a good idea - because if your UltraComboEditor is translating DataValue to DisplayText, then this will mean that existing rows that are pointing to deleted values will no longer get translated. And since the UltraComboEditor services the entire column, this will affect other cells in the column in addition to the one you happen to have dropped down.
A better solution would be to use UltraDropDown instead of UltraComboEditor. UltraDropDown allows you to hide rows without removing them. So you can simply hide the rows for options that are deleted. But since they are still on the list and just hidden, the grid will still be able to translate those DisplayText and DataValues. And the user wont be able to select the deleted/hidden options on the list.
I don't want to force users to modify records that already reference deleted records. They should be able to select all the active records, plus one deleted record that is currently being referenced by the row.
In a scenario where we have two active categories (say IDs 1 and 2) and two deleted categories (IDs 3 and 4). And we have two rows, first referencing deleted category 3 and the other referencing deleted category 4. So for first row, I would like to list categories 1, 2 and 3. For second row, I'd like users to be able to select from categories 1, 2, and 4.Thanks