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

Change row style when field value is null

1 Answer 1270 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Orit
Top achievements
Rank 1
Orit asked on 23 Jun 2009, 10:29 AM
Hi

I want to change the style of a row when some fiekd is null
here is my code
<telerik:RadGridView.Resources>   
<Style TargetType="{x:Type telerik:GridViewRow}">  
<Style.Triggers> 
<DataTrigger Binding="{Binding Path=ParentID}" Value="NULL">  
<DataTrigger.Setters> 
<Setter Property="FontSize" Value="14" /> 
<Setter Property="FontWeight" Value="Bold" /> 
</DataTrigger.Setters> 
</DataTrigger> 
</Style.Triggers> 
</Style> 
</telerik:RadGridView.Resources> 
it doesnt work.

thanks.

1 Answer, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 23 Jun 2009, 12:50 PM
Hi Orit,

You will need to use the x:Null Markup Extension. "NULL" is simply the string "NULL" and has no special meaning to the compiler. Here is how to do this:

<Window x:Class="Ticket209422_RowStyleAccordingToDataItem.Window1" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" 
    Title="Window1" Height="300" Width="300"
    <Grid> 
        <telerik:RadGridView Name="RadGridView1" ColumnsWidthMode="Auto"
            <telerik:RadGridView.Resources> 
                <Style TargetType="{x:Type telerik:GridViewRow}"
                    <Style.Triggers> 
                        <DataTrigger Binding="{Binding Path=DigitalSignature}" Value="{x:Null}"
                            <DataTrigger.Setters> 
                                <Setter Property="Background" Value="Red" /> 
                                <Setter Property="FontSize" Value="14" /> 
                            </DataTrigger.Setters> 
                        </DataTrigger> 
                    </Style.Triggers> 
                </Style> 
            </telerik:RadGridView.Resources> 
        </telerik:RadGridView> 
    </Grid> 
</Window> 
 

I have prepared a small sample project that demonstrates this. Please, examine the sample and let me know if you have any other questions.

All the best,
Ross
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.
Tags
GridView
Asked by
Orit
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Share this question
or