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

Horizontal Auto Scrolling Behavior on Cell Click

5 Answers 115 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 2
Mike asked on 10 Sep 2009, 02:15 PM

Hello,

I have several custom width columns in my RadGrid and when I click in a cell that is partially displayed the grid horizontally auto scrolls to bring the entire column into view.  This functionality is great in most cases but when the column contains buttons it causes undesired results. 

IE: Cell contains several buttons but the entire cell isn’t visible within the grid.  When the user clicks the first button the grid auto scrolls, bringing the column into view, but the button click event that fires is for one of the hidden buttons instead of the button clicked.  We think this is happening because the auto scrolling fires before the click event and since the mouse cursor in now on a new button after the scrolling it fires that event instead of first clicked button.

One of two solutions will work for me.

1.  Either suppress the auto horizontal scrolling so the column doesn’t shift into view.

Or

2.  Make sure the proper button click event fires.

How do I make either of these happen?

Regards,
Mike

5 Answers, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 11 Sep 2009, 01:37 PM
Hi Mike,

You can do the first by using a custom grid behavior. Please look at the sample below:

this.radGridView1.GridBehavior = new CustomGridBehavior(); 
 
public class CustomGridBehavior: BaseGridBehavior 
    protected override bool OnMouseDownLeft(MouseEventArgs e) 
    { 
        RadButtonElement button = this.GridControl.ElementTree.GetElementAtPoint(e.Location)  as RadButtonElement; 
        if (button != null
        { 
            return false
        } 
        return base.OnMouseDownLeft(e); 
    } 

We will consider changing the scrolling behavior in one of our future versions. If you have more questions, feel free to write us back.

Kind regards,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Mike
Top achievements
Rank 2
answered on 01 Oct 2009, 02:15 PM
Hi Jack,

Sorry I thought this was resolved but it isn't.

Okay, yes it does suppress the auto horizontal scrolling but now the grid row doesn't select.

IE:  If I have 10 rows with the first one selected, and I click row 5 in the button area.  The custom event suppresses the selection of the row the button was clicked in leaving the first row selected.  This is a problem because I gather the data from that row based on the action of the button.

~Mike
0
Jack
Telerik team
answered on 01 Oct 2009, 04:31 PM
Hi Mike,

Thank you for writing me back.

Yes, I understand the issue. It is not possible to select the row without scrolling. However, you can use the OnMouseDownLeft event to process the data. Just get the correct row info from the button. Here is a sample:

protected override bool OnMouseDownLeft(MouseEventArgs e) 
    RadButtonElement button = this.GridControl.ElementTree.GetElementAtPoint(e.Location) as RadButtonElement; 
    if (button != null
    { 
        GridViewDataRowInfo rowInfo = (GridViewDataRowInfo)((GridCellElement)button.Parent).RowInfo; 
        //... 
        return false
    } 
    return base.OnMouseDownLeft(e); 

I hope this helps a little. If you have further questions, don't hesitate to contact me.

Best wishes,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Mike
Top achievements
Rank 2
answered on 15 Oct 2009, 02:13 PM
Hello,

After thinking about this issue heavily I have concluded this is really a bug.

Here is my logic.

If you allow me to add a RadMenu within the RadGrid then I anticipate the RadMenu would work correctly; the button I click fires that button's click event.  But since the click event that fires is not the correct event because of the auto scrolling either the RadMenu has a bug or the RadGrid does.  Either way this doesn't work as expected.

I would suggest either...

1.  Make auto scrolling a property
2.  Or fix the event order

The two suggestions in this thread work but not 100%.  It is not very functional to have the user select a row but not highlight it.  When the user goes back to the grid they need to re-scan the grid items to see which item was last selected.  Not very user friendly.

Regards,
Mike

0
Jack
Telerik team
answered on 19 Oct 2009, 11:59 AM
Hello Mike,

Yes, you have a point. I logged the issue and we will consider that when we plan our next version. Should you have any other questions, don't hesitate to ask.

Best wishes,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
Mike
Top achievements
Rank 2
Answers by
Jack
Telerik team
Mike
Top achievements
Rank 2
Share this question
or