VirtualGridDropDownListEditor crash on alpha numeric key pressed

2 posts, 0 answers
  1. Amand
    Amand avatar
    23 posts
    Member since:
    Aug 2012

    Posted 22 Dec 2016 Link to this post

    Hi,

    Aft

    After experiencing a crash when pressing any alpha-numeric key on a cell containing a VirtualGridDropDownListEditor, I spotted an error in Telerik source code at file RadGridView\VirtualGrid\Input\VirtualGridInputBehavior.cs (around line 1441) :

    protected virtual bool HandleAlphaNumericKey(KeyPressEventArgs keys)
    {
     
        ...
     
        else if (this.GridElement.ActiveEditor is VirtualGridDropDownListEditor)
        {
            string symbol = keys.KeyChar.ToString();
            RadDropDownListEditor editor = this.GridElement.ActiveEditor as RadDropDownListEditor;
            RadDropDownListEditorElement element = editor.EditorElement as RadDropDownListEditorElement;
     
            if ((element.AutoCompleteMode & AutoCompleteMode.Append) == AutoCompleteMode.Append)
            {
             
                ...

     

    The editor variable should be cast as VirtualGridDropDownListEditor

    Just to let you know for next releases
    Sorry if bug has already been spotted and fixed :)

    Regards

  2. Dimitar
    Admin
    Dimitar avatar
    1871 posts

    Posted 23 Dec 2016 Link to this post

    Hi Amand,

    Thank you for reporting this.

    Indeed this is an issue which I have logged in our Feedback Portal. I have added a vote for it on your behalf as well. You can track its progress, subscribe for status changes and add your comment to it here. I have also updated your Telerik Points.

    To workaround this you should create custom behavior:
    radVirtualGrid1.VirtualGridElement.InputBehavior = new MyBehavior(radVirtualGrid1.VirtualGridElement);
      
    class MyBehavior : VirtualGridInputBehavior
    {
        public MyBehavior(RadVirtualGridElement element) : base(element)
        {
      
        }
        protected override bool HandleAlphaNumericKey(KeyPressEventArgs keys)
        {
            if (!this.GridElement.IsInEditMode &&
                (this.GridElement.BeginEditMode == RadVirtualGridBeginEditMode.BeginEditOnKeystroke ||
                 this.GridElement.BeginEditMode == RadVirtualGridBeginEditMode.BeginEditOnKeystrokeOrF2))
            {
                //this.GridElement.HideContextMenu();
                this.GridElement.BeginEdit();
                if (this.GridElement.ActiveEditor is VirtualGridDropDownListEditor)
                {
                    string symbol = keys.KeyChar.ToString();
                    var editor = this.GridElement.ActiveEditor as VirtualGridDropDownListEditor;
                    var element = editor.EditorElement as RadDropDownListEditorElement;
      
                    if ((element.AutoCompleteMode & AutoCompleteMode.Append) == AutoCompleteMode.Append)
                    {
                        int index = element.AutoCompleteAppend.FindShortestString(symbol);
      
                        if (index == -1)
                        {
                            element.EditableElementText = symbol;
                            element.EditableElement.SelectionStart = 1;
                            element.EditableElement.SelectionLength = 0;
      
                            return true;
                        }
                    }
                     
                }
                return false;
            }
      
            return base.HandleAlphaNumericKey(keys);
        }
    }

    Should you have any other questions do not hesitate to ask.

    Regards,
    Dimitar
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 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