Hello,
I have a xamDataGrid where in i am displaying several columns from my datasource. Also the very first column is RecordNumber Column which is by default provided by xamDataGrid Control.
I am a bit unsure about naming this RecordNumber Column. Let's say I want to mention the column header name as "Sequence No" for this RecordNumber Column. It will be helpful if someone can suggest a solution for this.
Thanks,
Abdi
Hello Abdeali,
Actually the Record Numbering feature of XamDataGrid does not allow you to set header for record selector column automatically. In order to achieve such functionality you have to update the template of HeaderPrefixArea or create a style and set it’s Content property to the text you want to display:
<Style TargetType="{x:Type igWPF:HeaderPrefixArea}"> <Setter Property="Content" Value="Sequence No"/></Style>
If you want to resize (make bigger) the space for the record selector, you have to set the RecordSelectorExtent property of the FieldLayoutSettings object of the XamDataGrid, something like this:
xamDataGrid1.FieldLayoutSettings.RecordSelectorExtent = 100;
One more suggestion I have in your scenario is to add a Field with BindingType equal to Unbound, so you can use it to display what you want. For example you can add a style for XamTextEditor and bind it’s Text property to the VisibleIndex of the Record, to which the editor is corresponding. This way you can create row numbers that will start from 0 and also you can use a converter if you with the row numbers to start from 1, like in the code snippet below. Also by using Field you can set the header you want.
<igWPF:Field Label="Sequence No" BindingType="Unbound" IsReadOnly="True" AllowEdit="False"> <igWPF:Field.EditorStyle> <Style TargetType="{x:Type igWPF:XamTextEditor}"> <Setter Property="Text" Value="{Binding Path=Record. VisibleIndex, Converter={StaticResource conv}, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type igWPF:CellValuePresenter}},Mode=OneWay}"/> </Style> </igWPF:Field.EditorStyle></igWPF:Field>
I have attached simple sample application, where you can test my suggestions.
Please let me know if you require any further assistance regarding this matter.
Sincerely, ZhivkoEntry Level Software Developer