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

GridView with AutoCompleteEditor: Limiting token to a single value

2 Answers 61 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mimi
Top achievements
Rank 1
Mimi asked on 17 Dec 2018, 09:17 PM

I've done some searching but was unable to find anything to help my specific case. I am using an AutoCompleteEditor class to enable drop down textboxes on my grid view, but I want to limit the token to 1 min and max. How can I do this? You may ask why I am using this instead of a ComboBoxColumn. The answer is: I have been instructed to not show any drop down arrows. 

Here is the class that I've taken from forums:

  class AutoCompleteEditor : RadTextBoxControlEditor
    {
        protected override Telerik.WinControls.RadElement CreateEditorElement()
        {
            return new RadAutoCompleteBoxElement();
        }

        public override void OnKeyDown(System.Windows.Forms.KeyEventArgs e)
        {
            RadAutoCompleteBoxElement element = this.EditorElement as RadAutoCompleteBoxElement;

            if (element.IsAutoCompleteDropDownOpen)
            {
                return;
            }

            base.OnKeyDown(e);
        }
    }

 

I am trying to validate data entered into the cell, but it looks like end users are able to select multiple values. I want to completely disable this ability and allow only a single value to be selected.

It would be much simpler to use a regular ComboBoxColumn, but I am unable to convince decision makers other wise.


2 Answers, 1 is accepted

Sort by
0
Accepted
Hristo
Telerik team
answered on 18 Dec 2018, 10:09 AM
Hi Mimi,

I can suggest using the GridViewComboBoxColumn with an enabled auto-complete and a hidden drop-down button. This way you will only have a single item selected, which will also be limited to the auto-complete data source. All you need to do is to handle the CellEditorInitialized event, please check my code snippet below: 
private void RadGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e)
{
    RadDropDownListEditor editor = e.ActiveEditor as RadDropDownListEditor;
    if (editor != null)
    {
        RadDropDownListEditorElement element = (RadDropDownListEditorElement)editor.EditorElement;
        element.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
        element.ArrowButton.Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
    }
}

I hope this will help. Let me know if you have other questions.

Regards,
Hristo
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.
0
Mimi
Top achievements
Rank 1
answered on 18 Dec 2018, 03:05 PM
How simple. Thank you very much, this resolves a lot of issues. Thank you!
Tags
GridView
Asked by
Mimi
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Mimi
Top achievements
Rank 1
Share this question
or