ComboBoxColumn IndexChanged

6 posts, 0 answers
  1. Marc
    Marc avatar
    63 posts
    Member since:
    Mar 2017

    Posted 13 Jun 2018 Link to this post

    Hello,

    I need help to use SelectedIndexChanged of ComboBoxColumn.

    ValueChanged of the GridView is to late.

     

    Regards,

    Marc

  2. Marc
    Marc avatar
    63 posts
    Member since:
    Mar 2017

    Posted 13 Jun 2018 in reply to Marc Link to this post

    I meant CellValueChanged is to late, not ValueChanged.
  3. Marc
    Marc avatar
    63 posts
    Member since:
    Mar 2017

    Posted 14 Jun 2018 Link to this post

    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

  4. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    4120 posts

    Posted 14 Jun 2018 Link to this post

    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.
  5. Marc
    Marc avatar
    63 posts
    Member since:
    Mar 2017

    Posted 14 Jun 2018 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    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

     

  6. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    4120 posts

    Posted 15 Jun 2018 Link to this post

    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.
Back to Top