We have a very odd requirement. The grid rows show existing data, which is not editable. It is provided for display purposes only. The user can then add rows. One of the columns is a combobox that is bound to a list of items.
The odd requirement is that the comboBox needs to provide a subset of the data when it is dropped down for editing.
Here is a scenario. The grid contains the following customer names and types:
The odd requirement is that the comboBox needs to provide a subset of the data when it is dropped down for editing.
Here is a scenario. The grid contains the following customer names and types:
- Jones Education Customer
- Smith Business Customer
- Baggins Residentical Customer
- Support System Customer
In order to get the customer type name to show up (instead of the customer type id) we need to bind the combobox to the full set of customer types. But when the user adds a new one, they cannot have the System Customer as an option in the list.
I am filtering out the items that we don't want and rebinding it. But the new list is ignored and the full list is populated.
Any tips?
My code is below:
Private Sub CustomerGridView_CellBeginEdit(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.GridViewCellCancelEventArgs) Handles CustomerGridView.CellBeginEdit
' The list of types available for selection is different from the list that is
' bound for display, so handle this here.
Dim DropDownListEditor As RadDropDownListEditor = TryCast(Me.CustomerGridView.ActiveEditor, RadDropDownListEditor)
If DropDownListEditor IsNot Nothing Then
If (CustomerGridView.Columns(e.ColumnIndex).Name = "Type") Then
Dim editorElement As RadDropDownListEditorElement = CType(DropDownListEditor.EditorElement, RadDropDownListEditorElement)
Dim filteredList = OriginalList.
Where(Function(d) d.IsSystem = false)
editorElement.DataSource = filteredList.ToList
End If
End If
End Sub