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

GridViewSelectColumn - need handle to Checked event

3 Answers 201 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Brian
Top achievements
Rank 1
Brian asked on 01 Jun 2011, 09:37 PM

My GridView includes a "check-box" column which needs to be data-bound.  Users did not like the usability of the GridViewCheckBoxColumn and have insisted that I use the GridViewSelectColumn.  To support data-binding, I am doing the following:

public class CustomGridViewSelectColumn : GridViewSelectColumn
{
    public override FrameworkElement CreateCellElement(GridViewCell cell, object dataItem)
    {
        var element = base.CreateCellElement(cell, dataItem);
        var checkBox = element as CheckBox;
        if (checkBox != null) checkBox.SetBinding(CheckBox.IsCheckedProperty, new Binding("IsReadyForUpload") { Source = dataItem, Mode = BindingMode.TwoWay });
        return element;
    }
}

However, I need to be notified when a user changes the value of the check-box.  Using the CustomGridViewSelectColumn above, how can I receive notification when "IsChecked" changes (my View needs to subscribe to an event of some kind)?

Thanks

3 Answers, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 07 Jun 2011, 10:13 AM
Hello Brian,

RadGridView's SelectionChanged event should be properly thrown and you may subscribe to it freely. If this approach doesn't fit your needs you may introduce a custom event in your column, as illustrated in the attached project. However, I wouldn't advise you to do this, since in this way you will keep unneeded references to cells' elements, which may result in performance issues if you are processing a large amount of data. 

Kind regards,
Ivan Ivanov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Pierre-Paul
Top achievements
Rank 1
answered on 21 Mar 2013, 11:57 PM
Please forget this message since it is nolonger necessary.  It was actually based on tests aiming at isolating the situation but I just found a mistake in the coding of these tests.   Hence, I found a way to support the scenario presented.  

Hi,
I still have a question on this subject.

In a grid having a GridViewSelectColumn implemented, every time we are clicking on a row, this row is becoming "Selected" and the SelectColumn is turn on and also the Grid.SelectionChanged event is thrown. 

In clicking on a second row, that second row is also becoming "selected" and therefore added to the Grid.SelectedItems collection. and the Grid.SelectionChanged event is thrown,
 
Lets look now at the following scenario

If we go back to the first instance and we click on it, its GridViewSelectColumn is changed and the Grid.SelectionChanged Event is thrown.
However, if we STAY on the same row and click repeatedly on the instance to turn on and off the SelectColumn Check box, there is no event thrown.

I actually need to react to every change of the SelectColumn Checkbox so relying on the SelectionChanged event is not sufficient.  

To support such a scenario, is there any event thrown every time the check box is changed?  or a way to simulate it ...


0
Ivan Ivanov
Telerik team
answered on 27 Mar 2013, 09:26 AM
Hello Pierre-Paul,

 Can you please clarify which version of RadControls you are currently using. I am testing it with Q1 2013 and it is working as expected. Please, refer to the attached test project.

Greetings,
Ivan Ivanov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Brian
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Pierre-Paul
Top achievements
Rank 1
Share this question
or