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

Designbug on columns with checkboxes?

7 Answers 113 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Monika Kogler
Top achievements
Rank 1
Monika Kogler asked on 26 Feb 2010, 03:19 PM
Hi,
i want to use checkboxes in several columns and therefore my code - for 1 gridview column - looks like this:
____________________________________________________________________

<telerik:GridViewDataColumn x:Name="colResultNT" Header="Result NT" IsReadOnly="True" IsEnabled="False" DataMemberBinding="{Binding ResultNt}">
                                </telerik:GridViewDataColumn>
                                <telerik:GridViewDataColumn x:Name="colReview" Header="Review Needed?" DataMemberBinding="{Binding IsReviewNeeded}">
                                    <telerik:GridViewDataColumn.CellStyle>
                                        <Style TargetType="GridView:GridViewCell">
                                            <Setter Property="Template">
                                                <Setter.Value>
                                                    <ControlTemplate TargetType="GridView:GridViewCell">
                                                        <CheckBox Margin="5,0,0,0"
                                                                HorizontalAlignment="Left"
                                                                VerticalAlignment="Center"
                                                                IsChecked="{Binding IsReviewNeeded, Mode=TwoWay}" />
                                                    </ControlTemplate>
                                                </Setter.Value>
                                            </Setter>
                                        </Style>
                                    </telerik:GridViewDataColumn.CellStyle>                                    
                                </telerik:GridViewDataColumn>  
____________________________________________________________________
This code works fine, but actually the vertical grid line on the right sight disappered (see attached screenshot). Any ideas why? How can i get it back?
Thx in advance
                            
                              

7 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 26 Feb 2010, 03:39 PM
Hi Monika,

Please use CellTemplate directly instead setting Template via Style:

<telerik:GridViewDataColumn x:Name="colResultNT" Header="Result NT" IsReadOnly="True" IsEnabled="False" DataMemberBinding="{Binding ResultNt}">
                                </telerik:GridViewDataColumn>
                                <telerik:GridViewDataColumn x:Name="colReview" Header="Review Needed?" DataMemberBinding="{Binding IsReviewNeeded}">
                                    <telerik:GridViewDataColumn.CellTemplate>
                                                    <DataTemplate>
                                                        <CheckBox Margin="5,0,0,0"
                                                                HorizontalAlignment="Left"
                                                                VerticalAlignment="Center"
                                                                IsChecked="{Binding IsReviewNeeded, Mode=TwoWay}" />
                                                    </DataTemplate>
                                    </telerik:GridViewDataColumn.CellStyle>                                    

                                </telerik:GridViewDataColumn>

Greetings,
Vlad
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
Monika Kogler
Top achievements
Rank 1
answered on 01 Mar 2010, 07:48 AM
I tried using a datatemplate before but this didn't work out for me. I need to check the ischecked property of the checkbox in the row_updating event -> with datatemplate the value of this property is always false. Therefore, i'm now using the controltemplate. And so i really need a solution for this designe issue. Please help!
0
Kalin Milanov
Telerik team
answered on 02 Mar 2010, 08:37 AM
Hi Monika Kogler,

The VerticalGridLines are in fact drawn by the cells. Thus when overriding the ControlTemplate of the grid you are removing the grid lines from that cell. Attached I have prepared a small example which replaces our content presenter for the cell with your checkbox thus keeping the grid lines. Please review it and let me know if you need any further assistance.

Greetings,
Kalin Milanov
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
Monika Kogler
Top achievements
Rank 1
answered on 04 Mar 2010, 10:12 AM
Thanks for the example - the design is now working :)
But I'm dealing with another problem: the CellValidating-Event is not working for my checkbox-columns. For all other datacolumns the event is raised, but for my custom checkbox-column it is not. Any suggestions?
Regards, Monika
0
Nedyalko Nikolov
Telerik team
answered on 09 Mar 2010, 04:08 PM
Hello Monika Kogler,

If you want to use CellValidating event you have to use slightly different approach. I'll try to clarify this a little. CellValidating event is fired only when GridViewCell is about to exit edit mode. In your case you update the underlying data object directly with a binding and GridViewCell never enters into edit mode. I'm attaching a sample application that demonstrates how you can meet your goals with a custom check box column (a little bit more powerful with built-in keyboard support for the "Space" key). Take a closer look at the CustomCheckBoxColumn class. Inside CreateCellEditElement() method you can apply a custom styling. For the sake of the example I've just add some margins.

Let me know how this works on your end.

Kind 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
Monika Kogler
Top achievements
Rank 1
answered on 07 Jun 2010, 04:05 PM
hi,
i now need to set this custom checkbox-column invisible or disable it (depending on a combobox value) programmatically. but your example ignores setting the isvisible-property or the isenable/isreadonly-property. could you please provide this example for me too?
thx in advance
0
Maya
Telerik team
answered on 09 Jun 2010, 04:12 PM
Hello Monika Kogler,

While preparing an example the following conflicts have appeared:
1. Is the ComboBox you are using inside the grid in a column for every row?
2. If this is the case, what are your expectations when the value in the ComboBox for the first row
 requires the column to be Visible and the value in the second row - to be Collapsed?


Best wishes,
Maya
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.
Tags
GridView
Asked by
Monika Kogler
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Monika Kogler
Top achievements
Rank 1
Kalin Milanov
Telerik team
Nedyalko Nikolov
Telerik team
Maya
Telerik team
Share this question
or