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

Autocomplete gridViewComboBoxColumn: Suggestion getting appended to input incorrectly

1 Answer 136 Views
GridView
This is a migrated thread and some comments may be shown as answers.
LT
Top achievements
Rank 1
LT asked on 08 Mar 2019, 07:51 PM

I have a GridViewComboBoxColumn whose autocomplete behavior is undesired upon first cell click. Users are entering in a value, but when they first try to do something their input isn't properly appending to what they type and instead appends the first suggestion entirely onto their input. Please see UndesiredBehavior.gif.

Strangely enough, if they delete everything in the cell or change it and go back to it later on, then the behavior is desired: suggestions are being appended properly to what their input is. Please see DesiredBehavior.gif.

I am having a work around right now by instructing users to CTRL + A upon first entering into the cell and then deleting whatever is appended to their first key stroke, and then typing again, but I get complaints from users that they shouldn't have to do this.

Here is my code. Any suggestions?

         private void radGridViewDetail_CellEditorInitialized(object sender, GridViewCellEventArgs e)
        {

            if (e.ActiveEditor is RadDropDownListEditor)
            {
                //RadDropDownListEditor editor = (RadDropDownListEditor)e.ActiveEditor;
                RadDropDownListEditor editor = this.radGridViewDetail.ActiveEditor as RadDropDownListEditor;
                if (editor != null)
                {
                    RadDropDownListEditorElement element = (RadDropDownListEditorElement)editor.EditorElement;
                    element.AutoCompleteSuggest.DropDownList.SelectAllText();
                    element.AutoCompleteSuggest.DropDownList.DropDownSizingMode = SizingMode.UpDownAndRightBottom; // This does not work
                    element.ArrowButton.Visibility = Telerik.WinControls.ElementVisibility.Collapsed; // This works
                    element.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
                    element.AutoCompleteSuggest.DropDownList.DropDownMinSize = new Size(275, 100);
                    element.AutoCompleteSuggest.DropDownList.MaxLength = 30;    
                switch (radGridViewDetail.CurrentColumn.Name)
                    {
                        case "CO":
                            element.AutoCompleteSuggest.DropDownList.DropDownMinSize = new Size(100, 100);
                            element.AutoCompleteDataSource = companyCodeTable;
                            element.AutoCompleteDisplayMember = "COMP_CODE";
                            element.AutoCompleteValueMember = "COMP_CODE";
                            element.DropDownWidth = 200;
                            break;
                        case "CC":
                            int minimumWidth = int.Parse(costCenterTable.Rows[0]["MAX_LEN"].ToString()) * 8;
                            element.AutoCompleteSuggest.DropDownList.DropDownMinSize = new Size(minimumWidth, 100);
                            element.AutoCompleteDataSource = costCenterTable;
                            element.DisplayMember = "ADDRESS";
                            element.ValueMember = "COST_CENTER";
                            element.AutoCompleteDisplayMember = "ADDRESS";
                            element.AutoCompleteValueMember = "COST_CENTER";
                            break;
                        case "Acct":
                            element.AutoCompleteSuggest.DropDownList.DropDownMinSize = new Size(275, 100);
                            element.AutoCompleteDataSource = glMajorTable;
                            element.DisplayMember = "ACCT_DESC";
                            element.ValueMember = "GLMAJOR";
                            element.AutoCompleteDisplayMember = "ACCT_DESC";
                            element.AutoCompleteValueMember = "GLMAJOR";
                            break;
                    }
                }
            }
        }

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 12 Mar 2019, 07:58 AM
Hello, Nguyen,    

When you add a GridViewComboBoxColumn, it is necessary to set its DataSource, DisplayMember and ValueMember properties in order to setup it properly. Then, it is just necessary to specify the GridViewComboBoxColumn.AutoCompleteMode property and set the DropDownStyle property to DropDown in order to allow suggesting the matches while typing. Nothing else will be required.

According to the provided sample code snippet, it seems that you handle the CellEditorInitialized event and change the DisplayMember and ValueMember properties. In addition, you specify the AutoCompleteDataSource which means that this collection will be used for the auto-complete functionality. It is not clear whether you have a DataSource applied to the GridViewComboBoxColumn or not.

I have prepared a sample project for your reference. Please refer to the attached zip file. Could you please give it a try and get back to me with further information whether the behavior is acceptable when testing on your end. Feel free to modify the project in a way to reproduce the experienced issue and get back to me with it so I can investigate the precise case. Thank you in advance. 

I am looking forward to your reply.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
LT
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or