This is a migrated thread and some comments may be shown as answers.

[Solved] RadComboBoxElement ShowPopup not working

1 Answer 120 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Phil
Top achievements
Rank 1
Phil asked on 31 Jul 2009, 03:36 PM
What I'm trying to do is to drop down a ComboBox when the cell has focus, removes a click.  I hooked the CellEditorInitialized with the code below to get the RadComboBoxElement and call ShowPopup. It does not show the Popup (dropdown) and in fact stops the dropdown from even happening (i.e. the dropdown arrow does nothing).

Not sure what I'm doing wrong here.....
Using Q2 09 release

Private Sub dgSALCellEditorInitialized(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.GridViewCellEventArgs) Handles RadGridView_SAL.CellEditorInitialized

If (Me.RadGridView_SAL.ActiveEditor IsNot Nothing) AndAlso (TypeOf Me.RadGridView_SAL.ActiveEditor Is RadComboBoxEditor) Then
            Dim editor As RadComboBoxEditor = TryCast(Me.RadGridView_SAL.ActiveEditor, RadComboBoxEditor)
            If Not editor Is Nothing Then
                Dim element As RadComboBoxElement = TryCast(editor.EditorElement, RadComboBoxElement)
                element.ShowPopup()
            End If

End If

1 Answer, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 04 Aug 2009, 11:41 AM
Hello Phil,

I got a little confused as to which category of RadControls your question refers to. If your question is about RadGridView for WinForms, you should inherit the default combo box editor and override its BeginEdit method. Here is a sample:

Sub radGridView1_EditorRequired(sender As Object, e As EditorRequiredEventArgs) 
    If e.EditorType = GetType(RadComboBoxEditor) Then 
        e.EditorType = GetType(MyComboBoxEditor) 
    End If 
End Sub 
 
Public Class MyComboBoxEditor 
    Inherits RadComboBoxEditor 
    Public Overloads Overrides Sub BeginEdit() 
        MyBase.BeginEdit() 
        (DirectCast(Me.EditorElement, RadComboBoxEditorElement)).ShowPopup() 
    End Sub 
End Class 

However, if you are referring to RadGrid for ASP.NET AJAX, as specified in your ticket details, you need the following server-side event:

    Protected Sub RadGrid1_ItemCreated(ByVal sender As ObjectByVal e As Telerik.Web.UI.GridItemEventArgs) 
        If TypeOf e.Item Is GridEditFormItem And e.Item.IsInEditMode Then 
            Dim item As GridEditFormItem = TryCast(e.Item, GridEditFormItem) 
            Dim editor As GridDropDownListColumnEditor = TryCast(item.EditManager.GetColumnEditor("Categories"), GridDropDownListColumnEditor) 
            editor.ComboBoxControl.OnClientLoad = "showCombo" 
        End If 
    End 

And the following client-side function:

function showCombo(sender, args) 
    setTimeout(function(){ 
        sender.showDropDown(); 
    }, 1); 

The above code references the drop down control inside the edit form of the grid item on initialization, and attaches a client-side onLoad event handler, where we simply set a timeout to show the drop down of the combo box.

I hope this helps. If you have any further questions, please don't hesitate to ask.

All the best,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Phil
Top achievements
Rank 1
Answers by
Jack
Telerik team
Share this question
or