I have a xamDataGrid that is bound to an IBindingList and is a hierarchy. I want to AllowAddNew on the child rows in the hierarchy but not on the parent rows.
My field layout settings look like this.
<igDP:FieldLayoutSettings AutoGenerateFields="False" AllowAddNew="True" AllowFieldMoving="WithinLogicalRow" SelectionTypeCell="Single" SelectionTypeField="None" SelectionTypeRecord="Single" AllowDelete="True">
My data grid looks like this
<igDP:XamDataGrid.FieldLayouts> <igDP:FieldLayout > <igDP:Field Name="OpportunityServiceName" Label="Service"> <igDP:Field.Settings> <igDP:FieldSettings AllowEdit="False" /> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="AnnualGrossRevenueAmount" Label="Gross Revenue"> <igDP:Field.Settings> <igDP:FieldSettings EditAsType="{x:Type sys:Double}"> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamNumericEditor}" > <Setter Property="Mask" Value="{}{double:11.2}"/> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="Lanes" Label="Lanes" /> </igDP:FieldLayout> <igDP:FieldLayout Key="Lanes"> <igDP:Field Name="Origin" Label="Origin" /> <igDP:Field Name="Destination" Label="Destination" /> <igDP:Field Name="LaneID" Visibility="Collapsed" /> </igDP:FieldLayout> </igDP:XamDataGrid.FieldLayouts>
The result is my parent rows have an add new row, my child rows do not, which is the opposite of what I want.
Is there a way to apply the AllowAddNew to just child rows?
Hi,
I am glad to hear your issue resolved. If you don't need any further assistance with this please conclude the forum thread by verifying an answer so this might help other forum users as well.
Thanks in advance.
Best regards Petar.
That did it. Thank you very much.
Excuse me for the typo, I mistook the AllowEdit in your xaml for the AllowAddNew. Here is what I meant:
<igDP:XamDataGrid.FieldLayouts>
<igDP:FieldLayout >
<igDP:FieldLayout.Settings>
<igDP:FieldLayoutSettings AllowAddNew="False" />
</igDP:FieldLayout.Settings>
<igDP:Field Name="OpportunityServiceName" Label="Service">
<igDP:Field.Settings>
<igDP:FieldSettings AllowEdit="False" />
</igDP:Field.Settings>
</igDP:Field>
<igDP:Field Name="AnnualGrossRevenueAmount" Label="Gross Revenue">
<igDP:FieldSettings EditAsType="{x:Type sys:Double}">
<igDP:FieldSettings.EditorStyle>
<Style TargetType="{x:Type igEditors:XamNumericEditor}" >
<Setter Property="Mask" Value="{}{double:11.2}"/>
</Style>
</igDP:FieldSettings.EditorStyle>
</igDP:FieldSettings>
<igDP:Field Name="Lanes" Label="Lanes" />
</igDP:FieldLayout>
<igDP:FieldLayout Key="Lanes">
<igDP:FieldLayoutSettings AllowAddNew="True" />
<igDP:Field Name="Origin" Label="Origin" />
<igDP:Field Name="Destination" Label="Destination" />
<igDP:Field Name="LaneID" Visibility="Collapsed" />
</igDP:XamDataGrid.FieldLayouts>
Please test this out and let me know if you require any further assistance on the matter.
Sincerely,
Petar Monov
Developer Support Engineer
Infragistics Bulgaria
www.infragistics.com/support
Not sure I follow your suggestion.
I played around a bit and now got the Add new row to show up in both the parent (near the label Service) and child (near the label Origin).
How do I suppress the parent addnew row while keeping the child addnew row?
Hello,
When you define hierarchical layouts in explicitly the second layout you define is applied to the second level of data. So in order to get the desired behavior you have to set:
<igDP:Field.Settings> <igDP:FieldSettings AllowEdit="False" /></igDP:Field.Settings>to the second FieldLayout only.
Please let me know if you require any further clarification on the matter.