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

AutoGenerated checkbox colum - set EditTriggers property

3 Answers 174 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 06 Feb 2014, 02:20 PM
I have a RadGridView that's bound to the DataView of a DataTable.  Whenever the underlying database table contains a boolean column, RadGridView appropriately (and automatically) renders that column using a GridViewCheckBoxColumn.  However, by default, it takes 3 mouse clicks to modify the value of any given checkbox.  I've read the help topics on reducing the click count to either 2 clicks or 1 click.

I'd like to start by setting the EditTriggers property for every GridViewCheckBoxColumn to "CellClick" - which according to the docs should reduce my click count to 2.  However, I'm not sure of the appropriate place to make that adjustment.  I assumed that from within the AutoGeneratingColumn event handler, I could detect the current column was a GridViewCheckBoxColumn and simply set the property there.

However, examining the arguments passed into that method (the RadGridView itself and a GridViewAutoGeneratingColumnEventArgs object), I didn't see anything which indicated the current column was a GridViewCheckBoxColumn.

I know I can *create* my own, new GridViewCheckBoxColumn from within that event handler, but is that really necessary since it already exists?  Also, in order to create my own column, I'd need to know that the current db column is indeed a Boolean (by *type*, not by field name) - which I haven't found a way to determine from within the event handler either.

I also tried to add the following Style to the view's XAML, but it didn't seem to have any effect:

<UserControl.Resources>
    <ResourceDictionary>
        <Style TargetType="telerik:GridViewCheckBoxColumn">
            <Setter Property="EditTriggers" Value="CellClick" />
        </Style>
    </ResourceDictionary>
</UserControl.Resources>

Note that I am using implicit styles that can be changed at runtime - in case that impacts the validity of the above style setting...

So, what's the best way to set the EditTriggers property on an AutoGenerated column?

Thanks,

Jeff

3 Answers, 1 is accepted

Sort by
0
Jeff
Top achievements
Rank 1
answered on 10 Feb 2014, 02:12 PM
Friendly bump...
0
Yoan
Telerik team
answered on 10 Feb 2014, 09:07 PM
Hello Jeff,

You can use the AutoGeneratingColumn event like so:
private void clubsGrid_AutoGeneratingColumn(object sender, GridViewAutoGeneratingColumnEventArgs e)
        {
            if (e.ItemPropertyInfo.PropertyType.FullName=="System.Boolean")
            {
                e.Column.EditTriggers = GridViewEditTriggers.CellClick;
            }
        }

I hope this helps.

Regards,
Yoan
Telerik

Check out the new Telerik Platform - the only modular platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native apps. Register for the free online keynote and webinar to learn more about the Platform on Wednesday, February 12, 2014 at 11:00 a.m. ET (8:00 a.m. PT).

0
Jeff
Top achievements
Rank 1
answered on 11 Feb 2014, 12:43 AM
Yoan,

That works as required - thank you.

Jeff
Tags
GridView
Asked by
Jeff
Top achievements
Rank 1
Answers by
Jeff
Top achievements
Rank 1
Yoan
Telerik team
Share this question
or