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

Grid with CheckBox question

8 Answers 211 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Simplex
Top achievements
Rank 1
Simplex asked on 29 Jun 2009, 07:41 PM
I can define a column to have a checkbox 2 ways. I way gives me one click change, the other I have to click 3 times to check or uncheck the box the first time. The second way is much shorter, but the first gives me the one click.

Just curious if this is a feature or bug?

This gives me the one click change:
                    <telerik:GridViewDataColumn  
                        HeaderText="Is Default with cell template"  
                        IsCustomSortingEnabled="True"  
                        IsFilterable="True" > 
                        <telerik:GridViewColumn.CellTemplate> 
                            <DataTemplate> 
                                <CheckBox  
                                    VerticalAlignment="Center" 
                                    IsChecked="{Binding Path=IsDefault}" 
                                /> 
                            </DataTemplate> 
                        </telerik:GridViewColumn.CellTemplate> 
                    </telerik:GridViewDataColumn> 

While this takes three clicks to change the value.
Click 1- set focus to the cell
Click 2- set control active
Click 3- change value.
                    <telerik:GridViewDataColumn  
                        HeaderText="Is Default"  
                        IsCustomSortingEnabled="True"  
                        IsFilterable="True"  
                        DataMemberPath="IsDefault"
                    </telerik:GridViewDataColumn> 

8 Answers, 1 is accepted

Sort by
0
Nedyalko Nikolov
Telerik team
answered on 01 Jul 2009, 01:25 PM
Hello Edward,

Indeed second implementation is the default one which is a little bit annoying. Second one is very good workaround, but still just a workaround. Of course we have plans to improve user experience of the editing, and it will be available very soon.

Kind regards,
Nedyalko Nikolov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
N_avtar
Top achievements
Rank 1
answered on 06 Jan 2010, 07:53 PM
HI,
I come up with the same solution but i got one bug in it. When i click on the checkbox it is working fine. But if i click on the cell, the check box is moving from center to right.
I am not sure what should i or what property should I change?
First image: The checkbox is on the right.
Second image: the checkbox is on the left if i select the cell.
Thanks,
N
 Code:

     <telerik:GridViewDataColumn DataMemberBinding="{Binding StudyDevice.StudyDevMotor.ChRotorCurrent,Mode=TwoWay}" Header="{Binding Source={StaticResource ProjectRes}, Path=LocalizedStrings.ChRotorCurrent}"
                           >
                            <telerik:GridViewDataColumn.CellTemplate>
                                <DataTemplate>

                                    <CheckBox IsChecked="{Binding StudyDevice.StudyDevMotor.ChRotorCurrent}" IsEnabled="True" Checked="OnChecked" Unchecked="OnUnchecked" />

                                </DataTemplate>
                            </telerik:GridViewDataColumn.CellTemplate>

                        </telerik:GridViewDataColumn>
Two imgage file attached.

0
N_avtar
Top achievements
Rank 1
answered on 06 Jan 2010, 09:00 PM
0
Joel Palmer
Top achievements
Rank 2
answered on 07 Jan 2010, 06:47 PM
When I implement the "one click change" scenario it displays the checkboxes appropriately and seems to perform 2 way binding.  However, when I attempt to sort the column by clicking on the column header, it gives me the following error:

"At least one object must implement IComparable."

Also, my other columns give me the option to filter.  Even though I have the properties set:

 

 

 

IsCustomSortingEnabled="True"   
 
IsFilterable="True" 
 
 
 

 

0
N_avtar
Top achievements
Rank 1
answered on 07 Jan 2010, 09:22 PM
Well,
i used this code to manager the checkbox inside the cell.
<telerik:GridViewDataColumn.CellStyle>
                                <Style>
                                    <Setter Property="CheckBox.BorderThickness" Value="5"></Setter>
                                    <Setter Property="CheckBox.HorizontalAlignment" Value="Right"></Setter>
                                    <Setter Property="CheckBox.IsEnabled" Value="{Binding TerminalVoltExist}"></Setter>
                                    <Setter Property="CheckBox.Visibility" Value="{Binding Converter={StaticResource CheckBoxVisible},  ConverterParameter=TerminalVoltExist}"></Setter>
                                </Style>
                            </telerik:GridViewDataColumn.CellStyle>

It is working good. But when the visibility is hidden. It is not showing even a cell. That is the problem.
I would like to make setting on checkbox, if the bit is zero, there should not be any checkbox in the cell.
Any suggestion please,
N
0
Nedyalko Nikolov
Telerik team
answered on 11 Jan 2010, 03:16 PM
Hi N_avtar,

I would like to recommend you using a CellTemplate property instead of CellStyle property in order to hide internal presenter. Your xaml should look like following:

<telerik:GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox x:Name="checkBox" IsChecked="{Binding IsActive}"
                                      Visibility="{Binding IsActive, Converter={StaticResource booleanToVisibilityConverter}}" />
                        </DataTemplate>

Let me know how this works on your end.

Hi Joel Palmer,

Can you provide me with some more information about your scenario? I need info such as - kind of the data source collection, type of the data property and any information that you find related to the problem. If you open a support ticket and attach a small project that I can debug on my side will be great. Thanks in advance.

All the best,
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
N_avtar
Top achievements
Rank 1
answered on 11 Jan 2010, 06:19 PM
Hi Nedyalko Nikolov,
It shows the same problem. When i double click on the cell, it shows up the check box. My code is :
 <telerik:GridViewDataColumn  DataMemberBinding="{Binding StudyPlotMotor.MotorSpeed}" Header="Motor Speed"
                            <telerik:GridViewDataColumn.CellTemplate> 
                                <DataTemplate> 
                                    <CheckBox Visibility="{Binding StudyPlotMotor.MotorSpeedExist,Converter={StaticResource CheckBoxVisible} }"  IsChecked="{Binding StudyPlotMotor.MotorSpeed}"  Checked="OnChecked" Unchecked="OnUnchecked" />                                     
                                </DataTemplate> 
                                 
                            </telerik:GridViewDataColumn.CellTemplate>                             
                            <telerik:GridViewDataColumn.CellStyle> 
                                <Style> 
                                    <Setter Property="CheckBox.HorizontalAlignment" Value="Right"></Setter> 
                                    
                                </Style> 
                            </telerik:GridViewDataColumn.CellStyle> 
                        </telerik:GridViewDataColumn> 
I dont want the check box visible if the checkboxexist bit is zero.
I just Wanted to achieve two simple steps:
(1) check if the checkboxExist bit is set then shows the checkbox in the cell
(2) if the checkbox data value is set then check the checkbox

Any suggestions,
Thanks,
N avatar
0
Nedyalko Nikolov
Telerik team
answered on 12 Jan 2010, 07:22 AM
Hello N_avtar,

When you double click on a cell you put that cell into edit mode, so with your xaml you will see the default editor which for a boolean column is a checkbox. If you do not to show this editor, just mark column as ReadOnly:

<telerik:GridViewDataColumn IsReadOnly="False" />


Best wishes,
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.
Tags
GridView
Asked by
Simplex
Top achievements
Rank 1
Answers by
Nedyalko Nikolov
Telerik team
N_avtar
Top achievements
Rank 1
Joel Palmer
Top achievements
Rank 2
Share this question
or