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

[Solved] Only select row if the column is checked?

6 Answers 111 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
plusHR
Top achievements
Rank 1
plusHR asked on 06 Jul 2011, 01:59 PM
Hi.

We have a gird with the view selector, however if you click in the row it automatically selects the check-box, therefore when you click the next row the current item is not updated.

We want it so that clicking from one record to the next correctly updates the selected/current item and the row is only "selected" when the user clicks the check-box in the grid view column selector and not for when they are clicking in the grid row. Could you assist?

Thanks
Paul

6 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 08 Jul 2011, 07:27 AM
Hello,

 Can you provide a bit more info about your scenario? Are you using our GridViewSelectColumn? 

Regards,
Vlad
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
plusHR
Top achievements
Rank 1
answered on 08 Jul 2011, 09:40 AM
Hi. Yes we are using the GridViewSelectColumn. When a user clicks a row in the grid, the selection column is automatically checked. We want it so that by default when a user clicks a row this is not selected. If they wish to select the row then they will click on the checkbox.

Thanks
Paul
0
Milan
Telerik team
answered on 11 Jul 2011, 01:55 PM
Hi Paul,

 Setting CanUserSelect to false will fulfill this scenario. 

Kind regards,
Milan
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
plusHR
Top achievements
Rank 1
answered on 11 Jul 2011, 02:34 PM
Thanks, that sorts the issue however we connect to the selectionchanged event as this is now only fired when the checkbox is selected. I have events that trigger when the record is changed, can you advise what event will fire each time the user clicks a row in the grid [without using the checkbox selector]?

P
0
Accepted
Milan
Telerik team
answered on 15 Jul 2011, 07:35 AM
Hello Paul,

You could simply subsrribe for for MouseLeftButtonDown event and move the code that was previsously executed in the event handler for SelectionChanged to an event handler of MouseLeftbuttonDown. For example:


public MainPage()
{
    InitializeComponent();
  
    this.playersGrid.AddHandler(FrameworkElement.MouseLeftButtonDownEvent, 
        new MouseButtonEventHandler(playersGrid_MouseLeftButtonDown), true);
}
  
void playersGrid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
    var senderElement = e.OriginalSource as FrameworkElement;
    var row = senderElement.ParentOfType<GridViewRow>();
  
    // if row was clicked
    if (row != null)
    {
        // execute code
    }
}




Greetings,
Milan
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
plusHR
Top achievements
Rank 1
answered on 15 Jul 2011, 12:40 PM
Thanks that sorted the problem, only further question is, can users select by row, as when they click on a row it is selecting the column, therefore our double click event is not always fired.

P
Tags
GridView
Asked by
plusHR
Top achievements
Rank 1
Answers by
Vlad
Telerik team
plusHR
Top achievements
Rank 1
Milan
Telerik team
Share this question
or