Hello
I have my Treeview setup to load on demand:
and then it is populated in code-behind:
I bind the dataform to the tree:
When I run, it works as expected with the dataform showing the detail for the item selected in the tree.
Save Edits (not working)
I would like to be able to edit in the dataform, and submit the changes back to the database. Is there an example on how to do this?
Thank you.
I have my Treeview setup to load on demand:
<
DataTemplate
x:Name
=
"Sub_SubLevel2"
x:Key
=
"DetailTemplate"
>
<
StackPanel
Orientation
=
"Horizontal"
>
<
TextBlock
Text
=
"Product ID: "
/>
<
TextBlock
Text
=
"{Binding ProductID}"
/>
</
StackPanel
>
</
DataTemplate
>
<
telerik:HierarchicalDataTemplate
x:Name
=
"SubLevel"
x:Key
=
"OrderTemplate"
ItemsSource
=
"{Binding Order_Details}"
ItemTemplate
=
"{StaticResource DetailTemplate}"
>
<
StackPanel
Orientation
=
"Horizontal"
>
<
TextBlock
Text
=
"Order ID: "
/>
<
TextBlock
Text
=
"{Binding OrderID}"
/>
</
StackPanel
>
</
telerik:HierarchicalDataTemplate
>
<
telerik:HierarchicalDataTemplate
x:Name
=
"Root"
x:Key
=
"CustomerTemplate"
ItemsSource
=
"{Binding Orders}"
ItemTemplate
=
"{StaticResource OrderTemplate}"
>
<
StackPanel
Orientation
=
"Horizontal"
>
<
TextBlock
Text
=
"Customer ID: "
/>
<
TextBlock
Text
=
"{Binding CustomerID}"
/>
</
StackPanel
>
</
telerik:HierarchicalDataTemplate
>
<
telerik:RadTreeView
Background
=
"WhiteSmoke"
Name
=
"radTreeView1"
ItemTemplate
=
"{StaticResource CustomerTemplate}"
ItemPrepared
=
"radTreeView_ItemPrepared"
IsLoadOnDemandEnabled
=
"True"
IsExpandOnSingleClickEnabled
=
"True"
LoadOnDemand
=
"radTreeView_LoadOnDemand"
/>
and then it is populated in code-behind:
this
.radTreeView1.ItemsSource = _Context.Customers;
var loadTree = _Context.Load(_Context.GetCustomersQuery(), LoadBehavior.RefreshCurrent,
true
);
I bind the dataform to the tree:
<
telerik:RadDataForm
x:Name
=
"radDataForm"
Header
=
"Title"
Grid.Column
=
"1"
CurrentItem
=
"{Binding Path=SelectedItem, ElementName=radTreeView1}"
/>
When I run, it works as expected with the dataform showing the detail for the item selected in the tree.
Save Edits (not working)
private
void
radDataForm_EditEnding(
object
sender, Telerik.Windows.Controls.Data.DataForm.EditEndingEventArgs e)
{
radDataForm.CommitEdit(
true
);
_Context.SubmitChanges(so =>
{
string
errorMsg =
string
.Empty;
if
(so.HasError)
{
errorMsg =
"failed"
;
}
else
{
errorMsg =
"succeeded"
;
}
MessageBox.Show(
"Update "
+ errorMsg);
},
null
);
}
I would like to be able to edit in the dataform, and submit the changes back to the database. Is there an example on how to do this?
Thank you.