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

GridView CellValidating/RowValidating events are not firing up

3 Answers 341 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Sega
Top achievements
Rank 1
Sega asked on 17 Dec 2012, 02:52 PM
Hi guys!

I have gridview with custom defined style for it's children. But when I set up cellvalidating | rowvalidating event, it's not fire up! Why??

GridView xaml:

<t:RadGridView Grid.Row="2" Style="{StaticResource OverrideDefaultGridViewStyle}" AddingNewDataItem="OnSpecGridViewAddingNewDataItem"
                       ItemsSource="{Binding Specifications, Mode=TwoWay}" x:Name="SpecGridView">
 
            <t:RadGridView.Resources>
                <DataTemplate x:Key="DraggedItemTemplate">
                    <StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{x:Static p:Resources.AddStandardWindow_TextBlock_Dragging}" />
                            <TextBlock Text="{Binding CurrentDraggedItem.SpecificationName}" FontWeight="Bold" />
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding CurrentDropPosition}" FontWeight="Bold" MinWidth="45" Foreground="Gray"/>
                            <TextBlock Text=", (" Foreground="Gray" />
                            <TextBlock Text="{Binding CurrentDraggedOverItem.SpecificationName}" Foreground="Gray" />
                            <TextBlock Text=")" Foreground="Gray" />
                        </StackPanel>
                    </StackPanel>
                </DataTemplate>
            </t:RadGridView.Resources>
 
            <t:RadGridView.Columns>
                <t:GridViewColumn>
                    <t:GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <t:RadButton Content="X" Click="OnDeleteSpecificationButtonClicked" Style="{StaticResource ButtonCustomStyleRed}" />
                        </DataTemplate>
                    </t:GridViewColumn.CellTemplate>
                </t:GridViewColumn>
                     
                <t:GridViewColumn Header="{x:Static p:Resources.AddStandardWindow_Specifications}">
                    <t:GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <TextBox Style="{StaticResource OverrideDefaultTextBoxStyle}" Text="{Binding SpecificationName}"/>
                        </DataTemplate>
                    </t:GridViewColumn.CellTemplate>
                </t:GridViewColumn>
 
                <t:GridViewColumn Header="{x:Static p:Resources.AddStandardWindow_Parameter}" Width="20*">
                    <t:GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <t:RadComboBox Style="{StaticResource ComboBoxStyle}" ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type t:RadWindow}}, 
                                            Path=DataContext.Parameters}" SelectedItem="{Binding Parameter}" DisplayMemberPath="ParameterName" />
                        </DataTemplate>
                    </t:GridViewColumn.CellTemplate>
                </t:GridViewColumn>
 
                <t:GridViewColumn Header="{x:Static p:Resources.AddStandardWindow_Nominal}" Width="20*">
                    <t:GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <TextBox Style="{StaticResource OverrideDefaultTextBoxStyle}" KeyDown="OnKeyDown" Text="{Binding Nominal, NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged}" SourceUpdated="OnNominalOrAccuracySourceUpdated">
                            </TextBox>
                        </DataTemplate>
                    </t:GridViewColumn.CellTemplate>
                </t:GridViewColumn>
 
                <t:GridViewColumn Header="{x:Static p:Resources.AddStandardWindow_Accuracy}"
                                  Width="10*" Background="#D8E5F0">
                    <t:GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <TextBox Style="{StaticResource OverrideDefaultTextBoxStyle}" KeyDown="OnKeyDown" Text="{Binding Accuracy,
                                NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged}" SourceUpdated="OnNominalOrAccuracySourceUpdated" />
                        </DataTemplate>
                    </t:GridViewColumn.CellTemplate>
                </t:GridViewColumn>
 
 
                <t:GridViewColumn Header="{x:Static p:Resources.AddStandardWindow_Precision}"
                                      Width="10*"
                                      Background="#D8E5F0">
                    <t:GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <TextBox KeyDown="OnKeyDown" Text="{Binding Presition, NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource OverrideDefaultTextBoxStyle}">
                            </TextBox>
                        </DataTemplate>
                    </t:GridViewColumn.CellTemplate>
                </t:GridViewColumn>
                                   
                <t:GridViewColumn Header="{x:Static p:Resources.AddStandardWindow_Min}" Width="10*">
                    <t:GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <TextBox Style="{StaticResource OverrideDefaultTextBoxStyle}" KeyDown="OnKeyDown" Text="{Binding Minimum, NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged}" SourceUpdated="OnMinOrMaxSourceUpdated">
                            </TextBox>
                        </DataTemplate>
                    </t:GridViewColumn.CellTemplate>
                </t:GridViewColumn>
                <t:GridViewColumn Header="{x:Static p:Resources.AddStandardWindow_Max}" Width="10*">
                    <t:GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <TextBox Style="{StaticResource OverrideDefaultTextBoxStyle}" KeyDown="OnKeyDown" Text="{Binding Maximum, NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged}" SourceUpdated="OnMinOrMaxSourceUpdated">
                            </TextBox>
                        </DataTemplate>
                    </t:GridViewColumn.CellTemplate>
                </t:GridViewColumn>
                <t:GridViewColumn Width="40">
                    <t:GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <Image Source="/Images/UpDown.png" Height="34" Width="34" Stretch="None"/>
                        </DataTemplate>
                    </t:GridViewColumn.CellTemplate>
                </t:GridViewColumn>
 
             
             
            </t:RadGridView.Columns>
        </t:RadGridView>

P.S. I am not using these events here in this xaml. IS there any work around?

Thank you,
Ihor.

3 Answers, 1 is accepted

Sort by
0
Vera
Telerik team
answered on 18 Dec 2012, 11:35 AM
Hello Sega,

 
Actually, CellValidating and RowValidating events fire when cell or row is about to commit new content, which means that the cell/row should be in edit mode. In your case, where you use TextBox in the CellTemplate of a GridViewColumn, the cell/row never gets in edit mode. That is why the events do not occur. I would suggest you to check our Validation help article for a reference. 

Kind regards,
Vera
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Sega
Top achievements
Rank 1
answered on 18 Dec 2012, 11:55 AM
Hi Vera! 

Thank you for your help! Does edit mode reachable in my case? How to achieve it?

Thanks!
0
Nedyalko Nikolov
Telerik team
answered on 19 Dec 2012, 11:25 AM
Hi,

Generally, the default template is TextBlock (view mode), because TextBlock requires far less resource in order to render, and cell edit template is TextBox (edit mode). Usually, double click will force RadGridView to put the current cell in edit mode. However, some controls like TextBox handled double click event and RadGridView does not understand that such action is performed.

Kind regards,
Nedyalko Nikolov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Sega
Top achievements
Rank 1
Answers by
Vera
Telerik team
Sega
Top achievements
Rank 1
Nedyalko Nikolov
Telerik team
Share this question
or