This is a migrated thread and some comments may be shown as answers.

Index out of bound error while deleting DomainService entity binded with radtreelistview

7 Answers 74 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Sudhir
Top achievements
Rank 1
Sudhir asked on 18 Jun 2012, 09:33 AM
Hi,

I have a self referential LinqToSql Entiy. I am using this entiy to bind to RadTreeListView to display the data as a Parent-Child relation. Fields are getting added successfully but I am getting error while deleting the Fields.

I am adding entity as

private void AddNewFieldCommand(object parameter)
{
Field newField = new Field()
newField.GrandParent = SelectedGrandParent;
SelectedGrandParent.Fields.Add(newField);
SelectedField = newField;
}


I am adding child field as
private void AddNewSubFieldCommand(object parameter)
 
       {
 
           if (SelectedGradParent != null && SelectedField != null)
 
           {
 
               Field newSubField = new Field();
 
               newSubField.ParentField= SelectedField;
 
               SelectedField.Fields.Add(newSubField);
 
               newSubField.GrandParent= SelectedGradParent ;
 
               SelectedField = newSubField;
 
           }
 
       }

and deleting the field as
private void DeleteFieldCommand(object parameter)
{
    try
    {
        if (parameter != null && parameter is Field)
        {
            Field selectedLocalField = parameter as Field;
            if (selectedLocalField.ParentField != null)
            {
                Field parentField = selectedLocalField.ParentField;
                DeleteFieldIteratively(context, selectedLocalField);
                //context is DomainContext 
            }
            else
            {
                GrandParent grandParent= selectedLocalField.GrandParent ;
                DeleteFieldIteratively(context, selectedLocalField);
                //context is DomainContext 
            }
            //SelectedField is current selected field
            if (selectedLocalField.Equals(SelectedField))
                SelectedField = null;
        }
    }
    catch (Exception ex)
    {
        ShowMessage(ex.Message);
    }
}
  
  
public static void DeleteFieldIteratively(DomainContext context, Field field)
{
    foreach (Field childField in field.Fields.ToList())
    {
        DeleteFieldIteratively(context, childField);
    }
  
    if (field.EntityState != EntityState.Detached && field.EntityState !=            
        EntityState.Deleted && field.EntityState != EntityState.New)
    {
        //if fields are from database
        context.Fields.Remove(field);
    }
    else
    {
        //If fields has been added from UI
        field.GrandParent = null;
        field.Parent = null; //Setting this throws the error

                                // I have also tested it using remove methods of the Parent's 
                                // Fields Collection as well as detaching the entity with no success
    }
}


When I am trying to delete field then I am getting the following error.

System.IndexOutOfRangeException occurred
  Message=Index was outside the bounds of the array.
  StackTrace:
       at Telerik.Windows.Controls.GridView.IndexTree.Set(Int32 index, Double value)
       at Telerik.Windows.Controls.GridView.IndexTree.set_Item(Int32 index, Double value)
       at Telerik.Windows.Controls.GridView.IndexTree.RemoveAt(Int32 index)
       at Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.OnItemsChanged(Object sender, ItemsChangedEventArgs args)
       at Telerik.Windows.Controls.GridView.GridViewBaseVirtualizingPanel.OnItemsChangedInternal(Object sender, ItemsChangedEventArgs args)
       at Telerik.Windows.Controls.GridView.GridViewBaseVirtualizingPanel.OnItemsChangedHandler(Object sender, ItemsChangedEventArgs args)
       at Telerik.Windows.Controls.GridView.GridViewItemContainerGenerator.OnItemRemoved(Object item, Int32 itemIndex)
       at Telerik.Windows.Controls.GridView.GridViewItemContainerGenerator.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
       at Telerik.Windows.Controls.GridView.GridViewItemContainerGenerator.Telerik.Windows.Data.IWeakEventListener<System.Collections.Specialized.NotifyCollectionChangedEventArgs>.ReceiveWeakEvent(Object sender, NotifyCollectionChangedEventArgs args)
       at Telerik.Windows.Data.WeakEvent.WeakListener`1.Handler(Object sender, TArgs args)
       at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
       at Telerik.Windows.Data.DataItemCollection.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       at Telerik.Windows.Data.DataItemCollection.OnCollectionViewCollectionChanged(NotifyCollectionChangedEventArgs e)
       at Telerik.Windows.Data.DataItemCollection.Telerik.Windows.Data.IWeakEventListener<System.Collections.Specialized.NotifyCollectionChangedEventArgs>.ReceiveWeakEvent(Object sender, NotifyCollectionChangedEventArgs e)
       at Telerik.Windows.Data.WeakEvent.WeakListener`1.Handler(Object sender, TArgs args)
       at Telerik.Windows.Data.QueryableCollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
       at Telerik.Windows.Data.QueryableCollectionView.ProcessSynchronousCollectionChangedWithAdjustedArgs(NotifyCollectionChangedEventArgs originalArguments, Int32 adjustedOldIndex, Int32 adjustedNewIndex)
       at Telerik.Windows.Data.QueryableCollectionView.ProcessSynchronousCollectionChanged(NotifyCollectionChangedEventArgs args)
       at Telerik.Windows.Data.QueryableCollectionView.ProcessCollectionChanged(NotifyCollectionChangedEventArgs args)
       at Telerik.Windows.Data.HierarchicalCollectionView.ProcessCollectionChanged(NotifyCollectionChangedEventArgs args)
       at Telerik.Windows.Data.HierarchicalChildCollectionView.ProcessCollectionChanged(NotifyCollectionChangedEventArgs args)
       at Telerik.Windows.Data.QueryableCollectionView.OnSourceCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
       at Telerik.Windows.Data.QueryableCollectionView.Telerik.Windows.Data.IWeakEventListener<System.Collections.Specialized.NotifyCollectionChangedEventArgs>.ReceiveWeakEvent(Object sender, NotifyCollectionChangedEventArgs args)
       at Telerik.Windows.Data.WeakEvent.WeakListener`1.Handler(Object sender, TArgs args)
       at System.ServiceModel.DomainServices.Client.EntityCollection`1.RaiseCollectionChangedNotification(NotifyCollectionChangedEventArgs args)
       at System.ServiceModel.DomainServices.Client.EntityCollection`1.Remove(TEntity entity)
       at ProjetName.Field.set_Parent_Field(Field value)
  InnerException:


I have been struggling to fix this issue for several days but no result till now :(

Please suggest me for the fix.

Thanks in advance.








7 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 18 Jun 2012, 10:32 AM
Hello,

 Can you post more info about the treelist version? Is it our latest Q2 2012? If not can you try our latest official binaries in your case to see what will be the result? 

Regards,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Sudhir
Top achievements
Rank 1
answered on 18 Jun 2012, 01:17 PM
Hi,

We are using the GridView Version 2011.1.419.1040.

Can u please let me know how can i get the latest version

0
Dimitrina
Telerik team
answered on 18 Jun 2012, 01:21 PM
Hi,

 You could download the trial of the latest RadControls for Silverlight here.

Kind regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Sudhir
Top achievements
Rank 1
answered on 19 Jun 2012, 06:29 AM

Hi,

There is no control like Telerik.Windows.Controls.RadTreeListView in new binary. Is Telerik not going to support this control anymore.

Regards
Maddy

 

 

0
Vlad
Telerik team
answered on 19 Jun 2012, 06:31 AM
Hello,

 Actually the control is still there. You can check our demos for more info. 

Regards,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Sudhir
Top achievements
Rank 1
answered on 20 Jun 2012, 11:09 AM
No its not working with the new control too :(
0
Accepted
Vlad
Telerik team
answered on 20 Jun 2012, 11:12 AM
Hi,

 As I said in my previous reply the control is still available and you can check the treelist demos here:
http://demos.telerik.com/silverlight/#TreeListView/FirstLook

Greetings,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
GridView
Asked by
Sudhir
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Sudhir
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or