Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
215
Combox in a XamDataGrid Field
posted

Hi,

What I'm trying to do is to bind a list of my objects to a xamdatagrid(11.2), with each property in the object showing up as a field. Here's exactly what I want to do.

I have a CollectionView property called NewReportColumns in the ViewModel which my XamDataGrid binds to. The collection view is instantiated as follows

NewReportColumns = new CollectionView(ReportColumns);


ReportColumns is a List<NewReportColumn>

The NewReportColumn has a bunch of properties. Like Name, ID, Visible and DropdownList.

Now this DropdownList is a List<NewDropdown>. And NewDropdown has a Name and ID.

The XamDataGrid has AutoGenerateFields as false and I have <Field> tag declared for the columns I want to see. The XamDataGrid handles the Name, ID and Visible columns automatically. Name and ID appear as textboxes in the Grid and Visible appears as a checkbox. I want the DropdownList to appear as a XamComboEditor.

Here is what I have right now..

igDP:XamDataGrid Theme="IGTheme"
                      Name="Fields_List"
                      DataSource="{Binding NewReportColumns, Mode=TwoWay}"
                      ActiveDataItem="{Binding SelectedRecord}" GroupByAreaLocation="None"
                      SelectedItemsChanged="Fields_List_SelectedItemsChanged" >
            <igDP:XamDataGrid.FieldLayoutSettings>
                <igDP:FieldLayoutSettings AutoGenerateFields="False"
                                      ExpansionIndicatorDisplayMode="Never"
                                      HighlightAlternateRecords="True"
                                      />
            </igDP:XamDataGrid.FieldLayoutSettings>
            <igDP:XamDataGrid.FieldSettings>
                <igDP:FieldSettings AllowEdit="True" AllowRecordFiltering="False"
                                AllowSummaries="True" SummaryDisplayArea="BottomFixed" />
            </igDP:XamDataGrid.FieldSettings>
            <igDP:XamDataGrid.FieldLayouts>
                <igDP:FieldLayout>
                    <igDP:FieldLayout.Fields>
                        <igDP:Field Name="DbColumnName" Label="Database Column" Width="150" ToolTip="Database field name" >
                            <igDP:Field.Settings>
                                <igDP:FieldSettings AllowEdit="False">
                                    <!-- This is the colouring related stuff
                                <igDP:FieldSettings.CellValuePresenterStyle>

                                    <Style TargetType="{x:Type igDP:CellValuePresenter}">

                                        <Setter Property="Background" Value="#000000"/>

                                    </Style>

                                </igDP:FieldSettings.CellValuePresenterStyle>-->
                                </igDP:FieldSettings>
                            </igDP:Field.Settings>
                        </igDP:Field>
                        <igDP:Field Name="DisplayName" Label="Display Name" Width="150" ToolTip="Name that appears on the Report" />
                        <igDP:Field Name="Visible" Label="Visible" Width="50" />
                        <igDP:UnboundField Name="DrilldownList" Label="Drill Downs" >
                            <igDP:Field.Settings>
                                <igDP:FieldSettings EditorType="{x:Type igDE:XamComboEditor}">
                                    <igDP:FieldSettings.EditorStyle>
                                        <Style TargetType="{x:Type igDE:XamComboEditor}">
                                            <Setter Property="ItemsSource" Value="{Binding Path=MyItem.InnerReport.ReportColumns[0].DrilldownList}" />
                                            <Setter Property="DisplayMemberPath" Value="ContextMenulabel" />
                                        </Style>
                                    </igDP:FieldSettings.EditorStyle>
                                </igDP:FieldSettings>
                            </igDP:Field.Settings>
                        </igDP:UnboundField>
                    </igDP:FieldLayout.Fields>
                </igDP:FieldLayout>
            </igDP:XamDataGrid.FieldLayouts>
        </igDP:XamDataGrid>

Any ideas on what I'm doing wrong and how I should go about it?

Edit: Changed the Problem stmt to explain it better.

  • 215
    Verified Answer
    posted

    Alright I got it to work

    Marianne's Second post on this link

    http://forums.infragistics.com/forums/t/65633.aspx
    was the answer for me.

    The only missing piece for me was the DataItem property.

    Here's what my xaml for the unbound field looks like (which works ofcourse..)

    <igDP:UnboundField Name="DrilldownList" Label="Drill Downs" >
        <igDP:Field.Settings>
            <igDP:FieldSettings EditorType="{x:Type igDE:XamComboEditor}" >
                <igDP:FieldSettings.EditorStyle>
                    <Style TargetType="{x:Type igDE:XamComboEditor}">
                        <Setter Property="ItemsSource" Value="{Binding DataItem.DrilldownList}"/>
                        <Setter Property="DisplayMemberPath" Value="ContextMenulabel"/>
                        <Setter Property="ValuePath" Value="ReportId"/>
                    </Style>
                </igDP:FieldSettings.EditorStyle>
            </igDP:FieldSettings>
        </igDP:Field.Settings>
    </igDP:UnboundField>

  • 215
    posted

    bumping the post since I changed the problem stmt to explain it better