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

Question: A question about Checkbox selection

9 Answers 144 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jorge Gonzalez
Top achievements
Rank 1
Jorge Gonzalez asked on 29 Jan 2010, 10:04 PM
Hello,
      I have to click 2 times in the cell holding the checkbox before I am finally able to change the value of the checkbox on the 3rd click.
      My datasource is a dataset. The last two columns of the datatable in the dataset are booleans so they appear as checkboxes on the grid.

I've come up with a partial solution, which I implement in the grids selectionchanged event. I got it down to 2 clicks:

int currCol;
string currColHeaderName;

currCol = ((Telerik.Windows.Controls.GridViewDataColumn)((Telerik.Windows.Controls.GridView.GridViewCellBase)(((Telerik.Windows.Controls.GridView.GridViewDataControl)(gridname)).CurrentCell)).Column).DisplayIndex;

currColHeaderName = ((Telerik.Windows.Controls.GridViewDataColumn)((Telerik.Windows.Controls.GridView.GridViewCellBase)(((Telerik.Windows.Controls.GridView.GridViewDataControl)(gridname)).CurrentCell)).Column).Header.ToString();
            
if ( currColHeaderName == "<Whatever>") 
     target_servers.Columns[currCol].DataControl.BeginEdit();

Note. I compare the header names because if I reorder the columns this code would not work if I were looking at the column position.

Is there a 1 click solution out there?

Thanks

9 Answers, 1 is accepted

Sort by
0
Nedyalko Nikolov
Telerik team
answered on 01 Feb 2010, 08:19 AM
Hi Jorge Gonzalez,

I'm attaching an example which demonstrates three different approaches to achieve one click edit on a check box column. The grid in example has three columns and the last one is Boolean. You have to uncomment other columns to see other solutions in action. I've left uncommented my personal choice for a CheckBox column. This custom column also has a keyboard support (you can change the value with a "Space" key when check box cell is current). Let me know how if this does not help.

P.S. Be aware that solution which uses CellTemplate is not recommended since this will by-pass validation mechanism of RadGridView control.

Greetings,
Nedyalko Nikolov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Jorge Gonzalez
Top achievements
Rank 1
answered on 26 Feb 2010, 05:29 PM
Hello Nedyalko Nikolov,
     I am autogenerating the grid but the examples you provided have helped me figure out the solution. Your examples indirectly assign the columns celltemplate property a datatemplate while autogeneration of columns does not:

1. Create a resource of type datatemplate like this (This goes in the resources section of the xaml file):
<DataTemplate x:Key="chkBox">
            <CheckBox></CheckBox>
        </DataTemplate>

2. In the autogeneratingcolumn event/method of the grid type this:

case "<A column name>":
   e.Column.CellTemplate = (DataTemplate)this.Resources["chkBox"];
                    
0
Jorge Gonzalez
Top achievements
Rank 1
answered on 28 Feb 2010, 11:56 PM
Hello,
    My last response was not very clear. If you add the datatemplate to the column's celltemplate property in the autogeneratingcolumn event/method you will be able to select the checkbox with one click.
0
Vladimir Herisse
Top achievements
Rank 1
answered on 08 Jun 2010, 07:37 PM
Hi Nedyalko Nikolov,

This doesn't seem to work with the latest library, any updates?

Best regards,

Vlad
0
Nedyalko Nikolov
Telerik team
answered on 11 Jun 2010, 10:29 AM
Hi Vladimir Herisse,

I'm attaching a modified version of the example with latest binaries.
By the way there is a built-in GridViewCheckBoxColumn (in latest version), and I added such column in the grid from the sample application.

Sincerely yours,
Nedyalko Nikolov
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
Vladimir Herisse
Top achievements
Rank 1
answered on 11 Jun 2010, 11:36 PM
Thank you!!!
0
Miguel Peixoto
Top achievements
Rank 1
answered on 10 Nov 2010, 04:10 PM
Hi !

I have a similar problem and the CellTemplate approach solved part of it. 

Now I need to catch some checkbox event (Checked or Unchecked) or, in alternative, catch the event CellEditEnded (which is never fired when using the CellTemplate approach). Any thoughts on this? :)

Thanks !
0
Nedyalko Nikolov
Telerik team
answered on 14 Nov 2010, 02:53 PM
Hi Miguel Peixoto,

You could hook for the CheckBox.Checked event within the CellTemplate xaml. Indeed CellEditEnded event is not fired, since RadGridView does not enter into edit mode.

Regards,
Nedyalko Nikolov
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
Miguel Peixoto
Top achievements
Rank 1
answered on 15 Nov 2010, 07:20 PM
Hi Nedyalko,

The CheckBox.Checked event did the trick :)
Thanks!
Tags
GridView
Asked by
Jorge Gonzalez
Top achievements
Rank 1
Answers by
Nedyalko Nikolov
Telerik team
Jorge Gonzalez
Top achievements
Rank 1
Vladimir Herisse
Top achievements
Rank 1
Miguel Peixoto
Top achievements
Rank 1
Share this question
or