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

VirtualGridDropDownListEditor crash on alpha numeric key pressed

1 Answer 53 Views
VirtualGrid
This is a migrated thread and some comments may be shown as answers.
Amand
Top achievements
Rank 1
Amand asked on 22 Dec 2016, 02:26 PM

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

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 23 Dec 2016, 09:39 AM
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.
Tags
VirtualGrid
Asked by
Amand
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or