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?
Thanks
- Talha Anwer
Hello,
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.
Sincerely,
Teodosia Hristodorova
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 was able to use UltraComboEditor by using the DataFilter (implementing IEditorDataFilter). My Convert() method looks like this:
I went for this because it looks simple, and we were already using UltraComboEditor. So we don't need to modify a lot of code that depended on UltraComboEditor.
I appreciate your help and suggestions on this issue
It is possible to achieve a required behavior using the UltraDropDown's InitializeRow, BeforeDropDown, and AfterCloseUp events. This will eliminate the need to create a new control derived from UltraDropDown.
The InitializeRow gets fired for every row in the UltraDropDown and there you could hide the row depending on its Deleted value.
The BeforeDropDown gets fired right before the drop down is about to drop down and there you could get the value in the grid's cell and make this row in the drop-down visible.
The AfterCloseUp gets fired after the drop-down has closed up and there could hide the deleted row from the drop-down if you keep it in a global variable.
Additionally, the UltraDropDown could be styled to look exactly as UltraComboEditor using the InitializeLayout where could be hidden the ID and Deleted columns, all column headers and set the width of the Category column to the value of the grid's cell, and set the border of the UltraDropDown's rows and cells to Transparent.
I have modified the previous sample in order to demonstrate this behavior and it could be found attached below. Please test it on your side and let me know if I may be of any further assistance.
3513.UltraGrid_UltraDropDown.zip
Yes, this approach actually works. However, I am wondering if I could write a control, maybe derived from UltraDropDown and use the control's events to achieve the same behavior. Without having to bind to UltraGrid events.
So then what I would do is use UltraDropDown (instead of UltraComboEditor) and handle the InitializeRow event of the control.
Handle the CellListDopDown event of the grid. Loop through the rows of the UltraDropDown and set the Hidden property on each row. If the row is Deleted and it's value does not match the current value of the cell, hide it.
But you will need to store the value of the current cell when the user enters that cell in case they drop down more than once. You could use AfterCellActivate for that.
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