saravanakumar subramaniam
Top achievements
Rank 1
saravanakumar subramaniam
asked on 12 Dec 2011, 01:57 PM
Hi,
I am using RadDataForm to show the Employee details. I have enabled Add, Edit, Delete, Save and Commit command buttons for the RadDataForm and it is working fine. Now i have added separate button called "NewEdit". If i click the this new button i need to move the RadDataForm to Edit mode and if click "NewSave" i need to save the Employee details.
In RadDataForm i did find any event to rise from the custom button click event. Is there any way to achieve this?
I am using RadDataForm to show the Employee details. I have enabled Add, Edit, Delete, Save and Commit command buttons for the RadDataForm and it is working fine. Now i have added separate button called "NewEdit". If i click the this new button i need to move the RadDataForm to Edit mode and if click "NewSave" i need to save the Employee details.
In RadDataForm i did find any event to rise from the custom button click event. Is there any way to achieve this?
3 Answers, 1 is accepted
0
HDC
Top achievements
Rank 1
answered on 23 Dec 2011, 07:56 PM
The only way that i found how to do this is by overriding the control template, here is how to do this:
http://www.telerik.com/help/silverlight/raddatafor-styles-and-templates-styling-raddataform.html
Create a class based on the RadDataForm:
From the template created with blend, change the target type to the above class:
In the above code i added the save button.
This is how you would then hook that up to the actual dataform
The "style" property is key here, you need to put the name of the style you created in blend.
I know that it is kind of complicated, but it is the only way that i know
Best Regards,
Peter
http://www.telerik.com/help/silverlight/raddatafor-styles-and-templates-styling-raddataform.html
Create a class based on the RadDataForm:
public class ExqiDataForm : RadDataForm
{
public static readonly DependencyProperty SaveCommandProperty = DependencyProperty.RegisterAttached(
"SaveCommand",
typeof(object),
typeof(ExqiDataForm),
null);
public object SaveCommand
{
get
{
return (object)GetValue(SaveCommandProperty);
}
set
{
base.SetValue(SaveCommandProperty, value);
//NotifyPropertyChanged("SaveCommand");
}
}
public static readonly DependencyProperty SaveCommandParameterProperty = DependencyProperty.RegisterAttached(
"SaveCommandParameter",
typeof(object),
typeof(ExqiDataForm),
null);
public object SaveCommandParameter
{
get
{
return (object)GetValue(SaveCommandParameterProperty);
}
set
{
base.SetValue(SaveCommandParameterProperty, value);
//NotifyPropertyChanged("SaveCommandParameter");
}
}
}
From the template created with blend, change the target type to the above class:
<ControlTemplate x:Key="RadDataFormTemplate" TargetType="custom:ExqiDataForm">
You can then change the Part_FooterPanel:
<
Border
x:Name
=
"FooterPanel_Background"
Background
=
"{StaticResource DataForm_FooterPanel_Background}"
Grid.Row
=
"4"
>
<
StackPanel
x:Name
=
"PART_FooterPanel"
HorizontalAlignment
=
"Right"
Orientation
=
"Horizontal"
>
<
telerik:RadButton
x:Name
=
"PART_SaveButton"
Content
=
"Save"
Command
=
"{TemplateBinding SaveCommand}"
CommandParameter
=
"{TemplateBinding SaveCommandParameter}"
Margin
=
"2,4,4,4"
MinWidth
=
"48"
MinHeight
=
"20"
telerik:StyleManager.Theme
=
"{StaticResource Theme}"
Visibility
=
"{Binding CommitButtonVisibility}"
/>
<
telerik:RadButton
x:Name
=
"PART_CommitButton"
Content
=
"{TemplateBinding CommitButtonContent}"
Command
=
"controls:RadDataFormCommands.CommitEdit"
Margin
=
"2,4,4,4"
MinWidth
=
"48"
MinHeight
=
"20"
telerik:StyleManager.Theme
=
"{StaticResource Theme}"
Visibility
=
"{Binding CommitButtonVisibility}"
/>
<
telerik:RadButton
x:Name
=
"PART_CancelButton"
Content
=
"{TemplateBinding CancelButtonContent}"
Command
=
"controls:RadDataFormCommands.CancelEdit"
Margin
=
"2,4,4,4"
MinWidth
=
"48"
MinHeight
=
"20"
telerik:StyleManager.Theme
=
"{StaticResource Theme}"
Visibility
=
"{Binding CancelButtonVisibility}"
/>
</
StackPanel
>
</
Border
>
In the above code i added the save button.
This is how you would then hook that up to the actual dataform
<
custom:ExqiDataForm
x:Name
=
"OrganizationUsersEditor"
ItemsSource
=
"{Binding DataView, ElementName=organizationUserDomainDataSource}"
AutoGenerateFields
=
"False"
AutoEdit
=
"True"
AutoCommit
=
"True"
CommandButtonsVisibility
=
"Edit,Cancel,Commit"
LabelPosition
=
"Above"
EditEnded
=
"RadDataFormEditEnded"
Width
=
"840"
Height
=
"550"
Style
=
"{StaticResource RadDataFormStyle}"
SaveCommand
=
"{Binding SaveCommand, Source={StaticResource vmOrganizationUser}}"
SaveCommandParameter
=
"{Binding ElementName=organizationUserDomainDataSource}"
>
The "style" property is key here, you need to put the name of the style you created in blend.
I know that it is kind of complicated, but it is the only way that i know
Best Regards,
Peter
0
Jeff
Top achievements
Rank 1
answered on 12 Feb 2012, 05:57 AM
Is this seriously the only way to do it??
0
Hi,
Maya
the Telerik team
You can use the built-in commands from RadDataFormCommands like BeginEdit and CommitEdit. Depending on where you want to place those buttons, you can either edit the template of RadDataForm and place them next to Ok and Cancel buttons or define them just below/above the data form.
The most appropriate approach is up to your specific requirements.
Maya
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>