6 Answers, 1 is accepted
We'll need some more information in order to simulate the issue. Could you please send us code inside AddingNewDataItem() and RowEditEnded() event handlers. Also we need some more details about data source and business object to which RadGridView is bound. A sample project that demonstrates the issue will be great.
Sincerely yours,
Nedyalko Nikolov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
public class PersonRelation:StandardGridClass
{
Guid personId;
public PersonRelation(Guid PersonId)
{
personId = PersonId;
}
public override void LoadData()
{
sf.rgv.IsBusy = true;
LoadOperation<HRM_Relation> load = domain.Load<HRM_Relation>(domain.GetHRM_RelationQuery());
load.Completed += new EventHandler(load_Completed);
}
void load_Completed(object sender, EventArgs e)
{
var load = sender as LoadOperation<HRM_Relation>;
sf.rgv.ItemsSource = load.Entities;
sf.rgv.IsBusy = false;
}
void add_Click(object sender, RoutedEventArgs e)
{
sf.rgv.BeginInsert();
}
public override void Delete()
{
foreach (var item in sf.rgv.SelectedItems)
{
domain.HRM_Relations.Remove(item as HRM_Relation);
}
if (!domain.IsSubmitting)
{
domain.SubmitChanges().Completed += new EventHandler(Submit_Completed);
}
}
public override void rgv_AddingNewDataItem(object sender, Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs e)
{
HRM_Relation NewObject = new HRM_Relation();
NewObject.RelationId = Guid.NewGuid();
NewObject.PersonId = personId;
e.NewObject = NewObject;
}
public override void rgv_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e)
{
PopUpMessageBox.Show(NotifyString.Updating, false);
if (e.EditAction == GridViewEditAction.Cancel)
{
PopUpMessageBox.Close(NotifyString.Updating, false);
return;
}
if (e.EditOperationType == GridViewEditOperationType.Insert)
{
domain.HRM_Relations.Add(e.NewData as HRM_Relation);
domain.SubmitChanges().Completed += new EventHandler(Submit_Completed);
}
if (e.EditOperationType == GridViewEditOperationType.Edit)
{
domain.SubmitChanges().Completed += new EventHandler(Submit_Completed);
}
}
}
Generally everything looks OK with your code. Indeed EntityCollection does not implement IList interface and RadGridView cannot add this item automatically, so you have to add it manually. But I cannot see any reason why there is a different behavior when RadGridView is empty and when there is item. Could you please send me a sample project that I can debug on my side?
Greetings,
Nedyalko Nikolov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.