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

Allow Selective Row Selection in GridView when using GridViewSelectColumn

2 Answers 49 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Vamshi
Top achievements
Rank 1
Vamshi asked on 12 Apr 2012, 02:42 AM
Hi,

I have a RadGridView with a GridViewSelectColumn. The objects that are bound to this gridview have a member called 'Status'. Now, if the status is a certain value i.e. 'Complete', I do'nt want the users to be able to select that particular row. I have tried to do "e.Row.IsEnabled = False;" in the RowLoaded event of the gridview, by checking the the value of 'Status' in that particular row. This prevents the users from selecting that row explicitly. However when users use the checkbox in the header row of the GridViewSelectColumn, thus performing a 'select all', the disabled rows also get selected. How do I prevent that?

Thanks in advance.

2 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 12 Apr 2012, 07:22 AM
Hi Vamshi,

You can try handling SelectionChanged event and remove all the items that cannot be selected. For example:

private void OnSelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs args)
        {
            foreach(var item in args.AddedItems)
            {
                if(((Club)item).Name == "Arsenal")
                {
                    this.clubsGrid.SelectedItems.Remove(item);
                }
            }
        }

You can customize the logic inside the handler so that it meets your requirements.  

Greetings,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Vamshi
Top achievements
Rank 1
answered on 12 Apr 2012, 05:54 PM
Hi Maya,

Thanks a lot. That works.

Vamshi.
Tags
GridView
Asked by
Vamshi
Top achievements
Rank 1
Answers by
Maya
Telerik team
Vamshi
Top achievements
Rank 1
Share this question
or