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

ComboBoxColumn IndexChanged

5 Answers 15 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Marc
Top achievements
Rank 1
Veteran
Marc asked on 13 Jun 2018, 12:37 PM

Hello,

I need help to use SelectedIndexChanged of ComboBoxColumn.

ValueChanged of the GridView is to late.

 

Regards,

Marc

5 Answers, 1 is accepted

Sort by
0
Marc
Top achievements
Rank 1
Veteran
answered on 13 Jun 2018, 01:54 PM
I meant CellValueChanged is to late, not ValueChanged.
0
Marc
Top achievements
Rank 1
Veteran
answered on 14 Jun 2018, 06:26 AM

I found a resolution:

METHOD PUBLIC VOID element_SelectedValueChanged( sender AS System.Object, e AS Telerik.WinControls.UI.Data.ValueChangedEventArgs ):
    DEFINE BUFFER btt-CSCompliance FOR tt-CSCompliance.
    
    DEFINE VARIABLE currentCell AS GridViewCellInfo NO-UNDO.
    
    IF gvCompliance:CurrentColumn:Index = 0 THEN DO:
        currentCell = gvCompliance:CurrentRow:Cells:Item[0].
        currentCell:EndEdit().
        END.
        
RETURN.

END METHOD.

 

 

But now I've got the next problem.

This works only for the first row/cell.

I think something missed after called the EndEdit()-Method.

Next time I've got a NullReferenceException.

 

Regards

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 14 Jun 2018, 11:44 AM
Hello, Marc,  

If I understand your requirement correctly, you need to detect when a new selection is made in the editor for the GridViewComboBoxColumn. For this purpose, you can use the CellEditorInitialized event where you have access to the RadDropDownListEditor and handle the RadDropDownListEditorElement.SelectedIndexChanged event as follows:
this.radGridView1.CellEditorInitialized += radGridView1_CellEditorInitialized;

private void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e)
{
    RadDropDownListEditor ddl = e.ActiveEditor as RadDropDownListEditor;
    if (ddl != null)
    {
        RadDropDownListEditorElement el = ddl.EditorElement as RadDropDownListEditorElement;
        el.SelectedIndexChanged -= el_SelectedIndexChanged;
        el.SelectedIndexChanged += el_SelectedIndexChanged;
    }
}
 
private void el_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
{
    Console.WriteLine(e.Position);
}

I hope this information helps. If you have any additional questions, please let me know. 

Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Marc
Top achievements
Rank 1
Veteran
answered on 14 Jun 2018, 11:58 AM

Hello Dess,

this is what I'm doing now.

I've forgotten the BeginEdit() after I set the EndEdit() manually.

METHOD PUBLIC VOID element_SelectedValueChanged( sender AS System.Object, e AS Telerik.WinControls.UI.Data.ValueChangedEventArgs ):
    DEFINE VARIABLE currentCell AS GridViewCellInfo NO-UNDO.
         
    IF gvCompliance:CurrentColumn:Index = 0 THEN DO:
            currentCell = gvCompliance:CurrentRow:Cells:Item[0].
            /* EndEdit() setzen, um CellValueChanged auszulösen */
            currentCell:EndEdit().
        END. /* IF gvCompliance:CurrentColumn:Index = 0 THEN DO: */
         
    RETURN.
 
END METHOD.

 

METHOD PRIVATE VOID gvCompliance_CellEditorInitialized( INPUT sender AS System.Object, INPUT e AS Telerik.WinControls.UI.GridViewCellEventArgs ):
    DEFINE VARIABLE myEditor    AS RadDropDownListEditor        NO-UNDO.
    DEFINE VARIABLE myElement   AS RadDropDownListEditorElement NO-UNDO.
        DEFINE VARIABLE currentCell AS GridViewCellInfo             NO-UNDO.
 
    myEditor = CAST(e:ActiveEditor, RadDropDownListEditor) NO-ERROR.
         
        IF myEditor <> ? THEN DO:
            myElement = CAST(myEditor:EditorElement, RadDropDownListEditorElement) NO-ERROR.
            myElement:SelectedValueChanged:Unsubscribe(element_SelectedValueChanged).
            myElement:SelectedValueChanged:Subscribe(element_SelectedValueChanged).
                 
            currentCell = gvCompliance:CurrentRow:Cells:Item[0].
            currentCell:BeginEdit().
        END. /* IF myEditor <> ? THEN DO: */
         
    RETURN.
 
END METHOD.

 

Now, everything is ok.

 

Regards

 

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 15 Jun 2018, 09:09 AM
Hello, Marc,  

I hope that the previous code snippet was useful for your case. Note that by default when you make a new selection from the drop down, the editor is not closed. It seems that you call the EndEdit method that closes the editor. The CellEditorInitialized event is fired when you already activated the editor. Hence, calling the BeginEdit method is not necessary in this event handler. It is difficult from the brief code snippet to get better understanding for the complete scenario that you have. But if the current behavior suits your requirement feel free to use it.

I hope this information helps. If you have any additional questions, please let me know. 

Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
GridView
Asked by
Marc
Top achievements
Rank 1
Veteran
Answers by
Marc
Top achievements
Rank 1
Veteran
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or