3

I have a RadGridView with binding to an ObservableCollection of TestType.

TestType contains 3 members:

string TestString;
Int TestInt;
List<string> TestCollection;

I added 3 record to the ObservableCollection.

The binding works, and I can see the records.

When i'm trying to edit the table, I can't edit the TestList member cell.

In winforms property grid i added an EditorAttribute like that:

[Editor typeof(CollectionUITypeEditor), typeof(UITypeEditor)].

And than, the member will be editable with a custom editor (in the property grid).

Is there anyway to make custom editor works at cell editting?

Tamir Vered
  • 10,187
  • 5
  • 45
  • 57
Hajaj
  • 49
  • 1
  • 7

1 Answers1

3

You need the CellEditTemplate: Setting CellTemplate and CellEditTemplate

<telerik:RadGridView x:Name="MyGrid" AutoGenerateColumns="False" ItemsSource="{Binding TestTypeList}">
    <telerik:RadGridView.Columns>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding TestString}" />
        <telerik:GridViewDataColumn DataMemberBinding="{Binding TestInt}" />
        <telerik:GridViewDataColumn DataMemberBinding="{Binding TestCollection}">
            <telerik:GridViewDataColumn.CellTemplate>
                <DataTemplate>
                    // Here give a template for the "TestCollection" when it is not in editing.
                </DataTemplate>
            </telerik:GridViewDataColumn.CellTemplate>
            <telerik:GridViewDataColumn.CellEditTemplate>
                <DataTemplate>
                    // Here give a template for the "TestCollection" when it is in editing.
                </DataTemplate>
            </telerik:GridViewDataColumn.CellEditTemplate>
        </telerik:GridViewDataColumn>           
    </telerik:RadGridView.Columns>
</telerik:RadGridView>

When you Bind a Simple type to the DataMemberBinding, Telerik give you a default "CellTemplate" and a default "CellEditTemplate" for the binded type.

But if you Bind a Complex type to the DataMemberBinding, Telerik doesn't know how to template it, so you need to give it your own Data Template for the normal state (CellTemplate) and for the Edit state (CellEditTemplate).

Community
  • 1
  • 1
Yehuda G.
  • 161
  • 1
  • 4