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

SL4 - GridView - Dataform as Custom Row

1 Answer 48 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 24 Mar 2011, 09:24 PM
Hi and thanks for your assistance.  I have RIA / DDS / Datagrid (child table).  I'm trying to move the construction of the grid up to XAML and use a custom row.  I've opted for trying to use a dataform so that I can get all the metadata goodness.  I am having trouble binding a combobox within this form.  Essentially I am trying to reproduce the following which was successful programmatically:

List<string> dropDownLoad_ArabicaRobusta = new List<string>();
dropDownLoad_ArabicaRobusta.Add("Arabica");
dropDownLoad_ArabicaRobusta.Add("Robusta");
cboColumn3.ItemsSource = dropDownLoad_ArabicaRobusta;
cboColumn3.UniqueName = "cboArabicaRobustaColumn";
cboColumn3.Header = "Species";
cboColumn3.DataMemberBinding = new Binding("robArab");
cboColumn3.DataMemberBinding.Mode = BindingMode.TwoWay;
cboColumn3.SortMemberPath = "robArab";
cboColumn3.Width = new GridViewLength(1, GridViewLengthUnitType.SizeToCells);

For the custom row definition, so far I have:

<ControlTemplate x:Key="tblPOLines_CustomRowTemplate" TargetType="telerik:GridViewRow">
                <dataForm:DataForm AutoGenerateFields="False" HorizontalAlignment="Stretch" CommandButtonsVisibility="None" 
                                   CurrentItem="{Binding}" AutoCommit="True" >
                    <Grid Width="Auto" HorizontalAlignment="Stretch">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <!--<TextBlock Text="Quantity" Grid.Column="0" Grid.Row="0"/>-->
                        <dataForm:DataField PropertyPath="unitQty" Grid.Column="0" Grid.Row="0" Grid.RowSpan="5" LabelPosition="Top" >
                            <TextBox x:Name="tb_Qty"  Text="{Binding Path=unitQty, Mode=TwoWay}" 
                                 HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16" Width="Auto" />
                        </dataForm:DataField>
                        <dataForm:DataField PropertyPath="isCert" Grid.Column="1" Grid.Row="0">
                            <CheckBox IsChecked="{Binding Path=isCert, Mode=TwoWay}" />
                        </dataForm:DataField>
-->                        <dataForm:DataField PropertyPath="robArab" Grid.Column="1" Grid.Row="1">
-->                          <ComboBox x:Name="cbo_robArab"  
-->                                SelectedValue="{Binding Path=robArab, Mode=TwoWay}" 
-->                                    ex:ComboBox.Mode="Async" >
-->                                <ComboBoxItem Content="Arabica" />
-->                                <ComboBoxItem Content="Robusta" />
-->                            </ComboBox>
-->                        </dataForm:DataField>
                        <dataForm:DataField Grid.Column="1" Grid.Row="3" PropertyPath="robArab" >
                            <TextBox x:Name="tb_robArab"  Text="{Binding Path=robArab, Mode=TwoWay}" Width="Auto" />
                        </dataForm:DataField>
                    </Grid>
                </dataForm:DataForm>
            </ControlTemplate>
<telerik:RadGridView HorizontalAlignment="Left" x:Name="dg_tblPOLines" VerticalAlignment="Stretch"
                             telerik:StyleManager.Theme="Expression_Dark"
                             Height="Auto" Width="Auto" Grid.Row="2" Grid.ColumnSpan="2"
                             ItemsSource="{Binding Path=CurrentItem.tblPOLines, Mode=TwoWay, ElementName=df_POLedger}" 
                             IsEnabled="True" IsReadOnly="True" ShowGroupPanel="True" 
                             AutoGenerateColumns="False"  IsFilteringAllowed="False" 
                             DataLoadMode="Asynchronous" CanUserDeleteRows="False" 
                             CanUserInsertRows="False" CanUserSelect="False" ShowInsertRow="False" 
                             CanUserFreezeColumns="False" CanUserResizeColumns="True"  
                             ActionOnLostFocus="CommitEdit" EditTriggers="CellClick" CurrentCellChanged="dg_tblPOLines_CurrentCellChanged" 
                             CellEditEnded="dg_tblPOLines_CellEditEnded" MaxWidth="835" MinWidth="825" ShowColumnFooters="True"
                             GridLinesVisibility="None" RowStyle="{StaticResource tblPOLines_rowStyle}">
           
            
              
        </telerik:RadGridView>


The textbox below it was to confirm all the information was coming through, and it is.  I have the metadata information fine.  The combobox has the two elements, no issue.  I am not able to bind it to the DDS with "{Binding Path=robArab, Mode=TwoWay}" and have the stored data in the database selected. 

Any help is appreciated.

1 Answer, 1 is accepted

Sort by
0
Mark
Top achievements
Rank 1
answered on 25 Mar 2011, 02:58 AM
Solution:

Moved the combobox items to (as a resource):

<toolkit:ObjectCollection x:Key="robArabList">
            <clr:String>Arabica</clr:String>
            <clr:String>Robusta</clr:String>
</toolkit:ObjectCollection>

Then binding at the combobox:

<dataForm:DataField PropertyPath="robArab" Grid.Column="1" Grid.Row="1">
                            <ComboBox x:Name="cbo_robArab"  
                                  ItemsSource="{Binding Source={StaticResource robArabList}}" SelectedItem="{Binding Path=robArab, Mode=TwoWay}" 
                                    ex:ComboBox.Mode="Async" >
                            </ComboBox>
</dataForm:DataField>
Tags
GridView
Asked by
Mark
Top achievements
Rank 1
Answers by
Mark
Top achievements
Rank 1
Share this question
or