RadGridView - auto open dropdown in comboboxcolumn

1 Answer 139 Views
DropDownList GridView
Daniel
Top achievements
Rank 2
Iron
Iron
Daniel asked on 11 Jan 2023, 12:56 PM

Hi Telerik support,

I've created a sample application with a gridview containing more combobox columns. In this forum I found some code snippets to auto open the dropdown box when one navigates to the cell (with the keybord arrow keys).

It seems to work fine except for one scenario..

click (with mouse) on the first column (which is readonly), then navigate to the next column with the arrowkey right. The focus jumps to the third column. If I navigate from the third column to the second (also with arrowkeys), it's ok.

Please try this also with column nr. 5 and 6. (so click on 5 and navigate to 6). After the application newly started, it also jumps away. But only the first time.

Can you help me out of this behaviour?

Kind regards,

Daniel Kaya

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Dinko | Tech Support Engineer
Telerik team
answered on 13 Jan 2023, 02:49 PM

Hello Daniel,

The provided project is greatly appreciated.

This is quite interesting behavior and it took me a while to investigate it. Let me try to explain. When the user clicks on the right arrow key, the next cell goes to edit mode by calling the BeginEdit() method. When the cell goes to edit mode, the key input is handled by the editor which on other hand triggers the selection of the next column cell on the same row. This is more a timing behavior. I would say that in this particular case, calling the BeginEdit() method in the CurrentCellChanged event won't be the best place to do that. What I can suggest instead is to custom GridBehavior. Inside the custom class, you can override the ProcessKey() method. Inside the method, you can call the BeginEdit() method by slightly delaying the execution of the method.

this.radGridView1.GridBehavior = new CustomGridBehavior();

public class CustomGridBehavior : BaseGridBehavior
{
    Timer timer = new Timer();        
    public override bool ProcessKey(KeyEventArgs keys)
    {
        var result = base.ProcessKey(keys);
        if((keys.KeyCode == Keys.Left || keys.KeyCode == Keys.Right) && this.GridControl.CurrentColumn is GridViewComboBoxColumn)
        {
            timer.Interval = 100;
            timer.Tick += Timer_Tick;
            timer.Start();                
        }
        return true;
    }

    private void Timer_Tick(object sender, EventArgs e)
    {
        timer.Stop();
        this.GridControl.BeginEdit();
    }
}

Using the above approach I am not able to observe anymore the reported behavior. Can you try it in your project?

Regards,
Dinko | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Daniel
Top achievements
Rank 2
Iron
Iron
commented on 17 Jan 2023, 10:08 AM

Hi Dinko,

Thanks for your reaction. I took over the code you provided and it looks ok now. I did had to raise the delay to 150ms. Now I can't reproduce the issue anymore.

Personally I'm not a big supporter of using sleep kind of things in applications. To me the issue looks like a Telerik bug. Can you confirm this? And if you confirm it, can you fix this in an upcoming release?

The fact that I had to raise the delay suggests that it's depended on the computer process speed. So when I deploy the application to production I have to be aware of this and it can differ on each computer. For now I can live with this but for the future I would be nice if Telerik solves this (if possible offcourse).

regards,

Daniel

Dinko | Tech Support Engineer
Telerik team
commented on 17 Jan 2023, 12:55 PM

I understand your point here. After a brief discussion with our development team, we can agree that this behavior is unexpected and could be handled internally. Therefore I have logged this in our Feedback Portal on your behalf so that you can track its progress and get notified of its status change. 

I have updated your Telerik Points for bringing this to our attention.

Daniel
Top achievements
Rank 2
Iron
Iron
commented on 17 Jan 2023, 12:57 PM

Thanks Dinko!

Tags
DropDownList GridView
Asked by
Daniel
Top achievements
Rank 2
Iron
Iron
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or