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

Observable collection binding to a datagrid

1 Answer 407 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Rahul
Top achievements
Rank 1
Rahul asked on 28 Mar 2011, 01:57 PM
<Grid>
        <StackPanel>
            <StackPanel>
                <StackPanel Orientation="Horizontal">
                    <Label Content="Enter Name"/>
                    <TextBox Height="25" Width="200" Background="AliceBlue" Text="{Binding Name}"/>
                </StackPanel>
                <StackPanel Orientation="Horizontal">
                    <Label Content="Enter Age"/>
                    <TextBox Height="25" Width="200" Background="AliceBlue" Text="{Binding Age}"/>
                </StackPanel>
           </StackPanel>
           <telerik:RadGridView Grid.Row="2" x:Name="orderView" ItemsSource="{Binding Order}" AutoGenerateColumns="False">
                <telerik:RadGridView.Columns>
                    <telerik:GridViewToggleRowDetailsColumn >
                        <!--<i:Interaction.Triggers>
                            <i:EventTrigger EventName="CellClick" >
                                <cmd:EventToCommand Command="{Binding Path=OrderCellClickCommand}" PassEventArgsToCommand="True" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>-->
                    </telerik:GridViewToggleRowDetailsColumn >
                    <telerik:GridViewSelectColumn Header="Select" x:Name="chkbox"/>
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding CustomerName}" Header="Name" />
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding Age}" Header="Age" />
                </telerik:RadGridView.Columns>
                <telerik:RadGridView.RowDetailsTemplate>
                    <DataTemplate >
                        <StackPanel >
                            <StackPanel Orientation="Horizontal">
                                <Label Content="Enter Name"/>
                                <TextBox Height="25" Width="200" Background="AliceBlue" Text="{Binding CustomerName}"/>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal">
                                <Label Content="Enter Age"/>
                                <TextBox Height="25" Width="200" Background="AliceBlue" Text="{Binding Age}"/>
                            </StackPanel>
                        </StackPanel>
                    </DataTemplate>
                </telerik:RadGridView.RowDetailsTemplate>
            </telerik:RadGridView>
            <Button Height="25" Width="80" Content="Add Order">
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="Click">
                        <cmd:EventToCommand Command="{Binding Path=AddOrderClickCommand}" PassEventArgsToCommand="True" />
                    </i:EventTrigger>
                </i:Interaction.Triggers>  
            </Button>
        </StackPanel>
    </Grid>
Hi,
I have a Observable collection bind to a datagrid dynamically.
I have used a RowDetailsTemplete to have same replica of view.
Here if i update anything in RowDetailsTemplet, it sholud update the Observable collection.
I set the Datcontext to DataTemplet but one row update reflects all other rows .
Please advice how i can achieve a particaular row tobe updated on Data changed in RowDataTemplate.
Also i need data tobe bind to RowDetailsTemplate on expand of row.

1 Answer, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 28 Mar 2011, 02:05 PM
Hello Rahul,

The DataContext of each Row Detail is the data item hosted in the row it belongs to. Don't set any DataContexts manually. This is done automatically for you.

Please, read the documentation before going on. Then take a look at this blog post.

I hope this helps.

Greetings,
Ross
the Telerik team
Tags
GridView
Asked by
Rahul
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Share this question
or