Hello,
i work with the last internal Build of DataForm (405), my problem, how can i do
validate? I use a RadWindow to edit data from a RadGrid.
DataFormLocation.ValidateItem() is allways false.
i work with the last internal Build of DataForm (405), my problem, how can i do
validate? I use a RadWindow to edit data from a RadGrid.
DataFormLocation.ValidateItem() is allways false.
<
telerik:RadWindow
x:Class
=
"SDLManager.Controls.WindowEditLocation"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
mc:Ignorable
=
"d"
d:DesignHeight
=
"420"
d:DesignWidth
=
"400"
>
<
Grid
x:Name
=
"LayoutRoot"
Background
=
"White"
Width
=
"350"
>
<
telerik:RadDataForm
Name
=
"DataFormLocation"
EditEnded
=
"DataFormLocation_EditEnded"
AutoGenerateFields
=
"True"
AutoGeneratingField
=
"DataFormLocation_AutoGeneratingField"
Margin
=
"4"
>
</
telerik:RadDataForm
>
</
Grid
>
</
telerik:RadWindow
>
using
System;
using
System.Windows;
using
SDLManager.Web;
using
Telerik.Windows.Controls;
using
Telerik.Windows.Controls.Data.DataForm;
namespace
SDLManager.Controls
{
public
partial
class
WindowEditLocation : RadWindow
{
#region Propeties
public
SDLmedia_Location NewLocation {
get
;
set
; }
public
bool
IsNew {
get
;
set
; }
#endregion
public
WindowEditLocation()
{
InitializeComponent();
}
public
WindowEditLocation(SDLmedia_Location location,
string
userName,
bool
isNew)
{
InitializeComponent();
IsNew = isNew;
if
(location !=
null
)
{
NewLocation = location;
NewLocation.CreatedByUser = userName;
NewLocation.CreatedDate = DateTime.Now;
}
else
{
NewLocation =
new
SDLmedia_Location();
NewLocation.CreatedByUser = userName;
NewLocation.CreatedDate = DateTime.Now;
NewLocation.Enabled =
true
;
}
DataFormLocation.CurrentItem = NewLocation;
DataFormLocation.BeginEdit();
}
private
void
DataFormLocation_EditEnded(
object
sender, EditEndedEventArgs e)
{
if
(e.EditAction == EditAction.Cancel)
{
NewLocation =
null
;
DataFormLocation.CancelEdit();
DialogResult =
false
;
Close();
}
if
(e.EditAction == EditAction.Commit)
{
if
(DataFormLocation.ValidateItem())
{
DialogResult =
true
;
Close();
}
else
{
DataFormLocation.CancelEdit();
DialogResult =
false
;
}
}
}
private
void
DataFormLocation_AutoGeneratingField(
object
sender, AutoGeneratingFieldEventArgs e)
{
e.DataField.Width = 340;
if
(IsNew)
{
if
(e.PropertyName.Equals(
"LocationID"
))
{
e.DataField.Visibility = Visibility.Collapsed;
}
}
else
{
if
(e.PropertyName.Equals(
"LocationID"
))
{
e.DataField.IsEnabled =
false
;
}
}
if
(e.PropertyName.Equals(
"CreatedDate"
))
{
e.DataField.IsEnabled =
false
;
}
else
if
(e.PropertyName.Equals(
"CreatedByUser"
))
{
e.DataField.IsEnabled =
false
;
}
}
}
}