GridViewDataColumn Binding not working

3 posts, 0 answers
  1. Eric
    Eric avatar
    36 posts
    Member since:
    Apr 2013

    Posted 15 Oct 2014 Link to this post

    I have the following RadGridView defined:                    

    <telerik:RadGridView Grid.Row="1" x:Name="gvUnits" ItemsSource="{Binding UnitsOfMeasure}" ColumnWidth="*" 
                                             AutoGenerateColumns="False"
                                             RowEditEnded="Entity_EditEnded"
                                             Deleted="Entity_Deleted"
                                             Margin="5">
                            <telerik:RadGridView.Columns>
                                <telerik:GridViewDataColumn Header="Name" DataMemberBinding="{Binding Name}" IsReadOnly="False"/>
                            </telerik:RadGridView.Columns>
                        </telerik:RadGridView>

    From what I've read there should be a default cell edit template, but when I click on an item I only get a blank box. I have also tried adding a custom celledittmplate as follows:

                        <telerik:RadGridView Grid.Row="1" x:Name="gvUnits" ItemsSource="{Binding UnitsOfMeasure, Mode=TwoWay}" ColumnWidth="*" 
                                             AutoGenerateColumns="False"
                                             RowEditEnded="Entity_EditEnded"
                                             Deleted="Entity_Deleted"
                                             Margin="5">
                            <telerik:RadGridView.Columns>
                                <telerik:GridViewDataColumn Header="Name" DataMemberBinding="{Binding Name}" IsReadOnly="False">
                                    <telerik:GridViewDataColumn.CellEditTemplate>
                                        <DataTemplate>
                                            <TextBox Text="{Binding Name}"/>
                                        </DataTemplate>
                                    </telerik:GridViewDataColumn.CellEditTemplate>
                                </telerik:GridViewDataColumn>
                            </telerik:RadGridView.Columns>
                        </telerik:RadGridView>
     Is there something else I need to do to make the text editable? Is it one-way binding by default?

    I'm sure this is an easy question, I'm just new to your controls.
  2. Boris
    Admin
    Boris avatar
    276 posts

    Posted 16 Oct 2014 Link to this post

    Hello Eric,

    I am not entirely sure what kind of data you have bound to your column. That is why I attached a sample project that demonstrates a common scenario with RadGridView. In general if you have a string property bound to the GridViewDataColumn, by default you will have a TextBox as an editor (CellEditTemplate) and a TextBlock as a CellTemplate. So by double clicking on a cell in that column, you will enter edit mode state (the default TextBox) for that cell.

    For more information about RadGridView you can refer to our documentation, online demos and sdk examples:
    1) Getting Started documentation article.
    2) Online Demos.
    3) SDK Examples - Although GitHub is a very well-known platform we saw a better and easier approach for reviewing our examples by developing our SDK Samples Browser


    I hope this helps.

    Regards,
    Boris Penev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Eric
    Eric avatar
    36 posts
    Member since:
    Apr 2013

    Posted 16 Oct 2014 in reply to Boris Link to this post

    Your example was very helpful, thank you. 

    I was missing a few references.
Back to Top