Wednesday, November 11, 2009

Using XamEditors in Infragistics XamDataGrid


Setting the Field’s EditorStyle property to a XamEditor control allows inline editing and updating of properties much easier inside a XamDataGrid. You can choose from a wide range of Editors from Infragisitcs and use it as the EditorStyle.
For editing a currency value in my Grid I have declared the FieldSettings as
<igdp:Field Label="Billed Amount" Name="BilledAmount" Column="1">
    <igdp:Field.Settings>
        <igdp:FieldSettings EditAsType="{x:Type sys:Decimal}">
            <igdp:FieldSettings.EditorStyle>
                <Style TargetType="{x:Type igEditors:XamCurrencyEditor}">
                    <Setter Property="Mask" Value="{}{currency:7.2:c}" />
                Style>
            igdp:FieldSettings.EditorStyle>                                   
        igdp:FieldSettings>
    igdp:Field.Settings>
igdp:Field>
Similarly for editing a value that should be selected from a combo box item collections.
<igdp:UnboundField  Name="ClientType" BindingPath="ClientType.Name" Label="Type" Column="4">
    <igdp:Field.Settings>
        <igdp:FieldSettings EditorType="{x:Type igEditors:XamComboEditor}">
            <igdp:FieldSettings.EditorStyle>
                <Style TargetType="{x:Type igEditors:XamComboEditor}">
                    <Setter Property="DisplayMemberPath" Value="Name" />
                    <Setter Property="ValuePath" Value="Id" />
                    <Setter Property="ItemsSource" Value="{Binding Path=DataContext.ClientTypeCollection,
                        RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}" />
                    <Setter Property="ValueType" Value="{x:Type entities:SampleClientType}" />
                    <Setter Property="IsAlwaysInEditMode" Value="False" />
                    <Setter Property="IsEditable" Value="False" />
                    <Setter Property="DropDownButtonDisplayMode" Value="OnlyInEditMode" />
                Style>
            igdp:FieldSettings.EditorStyle>
        igdp:FieldSettings>
    igdp:Field.Settings>
igdp:UnboundField>
Output screens











3 comments:

Unknown said...

Hello Prajeesh, Your post helped me to solve my problem. I tried using DataGrid Field but it didnt work well when binding to an ItemSource from its Ancestor. This Unbound column approach is really cool and working well for me. Thank you for posting this solution here!!

Monica said...

Hi Prajeesh,

Your Post was really helpful to me, Thanks a lot.

I found you very knowledgable in this topic, can you help me, Ive been using Infragistics for a while and to be honest theyre rubbish ! The visual designers dont work properly, setting layouts causes endless problems. Ive spent hours trying to figure out why when I set a tab control layout in designer, it appears completely differently at runtime. I have to wait days for answers to problems, when they issue updates, this causes existing fuinctioality to break, the list goes on and on. Im thinking of buying the Telerik set, has anyone used them ?

Anonymous said...

Hi Prajeesh,

Nice post. Very helpful.

Vishal