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

Disable row selection

4 Answers 178 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jurjen Ladenius
Top achievements
Rank 2
Jurjen Ladenius asked on 02 Feb 2011, 02:20 PM
Hi,

I wish to disable the row selection checkbox for rows based on content criteria.
I'm binding with an observable collection of objects that implement INotifyPropertyChanged.
Let's say that each object has a CanSelect boolean property.
What is the best way to disable the checkbox?

I've tried:

private

 

 

void myGrid_RowLoaded(object sender, Telerik.Windows.Controls.GridView.RowLoadedEventArgs e) {
    var theObject = e.DataElement as TheObject;
    if (theObject != null)
    {
        e.Row.Cells[0].IsEnabled = theObject.CanSelect;
    }
}

This doesn't work, since I can select disabled checkboxes, because I can select the row by clicking it.

Kind regards,

Jurjen

 

 

 

 

 

4 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 02 Feb 2011, 02:30 PM
Hello Jurjen Ladenius,

Why not setting the whole row to be disabled?

e.Row.IsEnabled = false;



Regards,
Veselin Vasilev
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Jurjen Ladenius
Top achievements
Rank 2
answered on 02 Feb 2011, 02:48 PM
That works quite well, but this has visual effects and all child controls get disabled, even when they've been explicitly enabled in the same routine.
I have some RadButtons in the grid that need to be enabled (opens a detail window)... Any suggestion?
0
Accepted
Veselin Vasilev
Telerik team
answered on 02 Feb 2011, 02:52 PM
Hello Jurjen Ladenius,

As an alternative you can subscribe to the SelectionChanging event of RadGridView and check the CanSelect property there. Cancel the event if the row should not be selected.

Best wishes,
Veselin Vasilev
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Jurjen Ladenius
Top achievements
Rank 2
answered on 02 Feb 2011, 03:36 PM
This gives me exactly the wanted functionality. Thanks!
Tags
GridView
Asked by
Jurjen Ladenius
Top achievements
Rank 2
Answers by
Veselin Vasilev
Telerik team
Jurjen Ladenius
Top achievements
Rank 2
Share this question
or