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

ClientOperation One node changes but multiple ClientOperation objects

2 Answers 61 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Relative
Top achievements
Rank 1
Relative asked on 20 Apr 2009, 10:18 PM
Hi,

Before I log a support ticket maybe someone can put my mind at rest.

I am updating my tree on the client and then doing a postback to process the changes. It all works but I am seeing what I think is odd / could be a bug. I am iterating over the ClientOperation objects as recommended but I am only updating one node per postback.

 foreach (ClientOperation<RadTreeNode> operation in rtvMenu.ClientChanges) 

On the updated node I am altering multiple propeties  - 3 in total (text / value and adding an attribute). I assumed that I would only have one ClientOperation object containing one node object but I get three and I examined each node in debugging and they are all the same with the updated values. I did a test with updating only one property and boom - one object. This doesn't make sense - Why send 3 objects when they are all on the same node, I am hitting the db 3 times with the same information this way. It would make sense if there was a flag on each object saying with propropery was changed but as far as i can see there isn't one. So is this a bug or is there some reason by design it is doing this?

Thanks,

Leon.

PS Subscription up in 30 days and renewing for another year is a no-brainer - Telerik tools make me look good ;)


2 Answers, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 21 Apr 2009, 06:59 AM
Hi Leon Mills,

This behavior is by design. A "property change" operation is generated for all three modified properties of the same node. You can check our online example. Here is an excerpt:

foreach (ClientOperation<RadTreeNode> operation in RadTreeView1.ClientChanges)
            {
                RadTreeNode node = operation.Item;

                switch (operation.Type)
                {
                    case ClientOperationType.Insert:
                        EventLogConsole1.LoggedEvents.Add("Added node with text: \"" + node.Text + "\"");
                        break;
                    case ClientOperationType.Remove:
                        EventLogConsole1.LoggedEvents.Add("Removed node with text: \"" + node.Text + "\"");
                        break;
                    case ClientOperationType.Update:
                        UpdateClientOperation<RadTreeNode> update = (UpdateClientOperation<RadTreeNode>)operation;
                        EventLogConsole1.LoggedEvents.Add("The \"" + update.PropertyName + "\" property of the \"" + node.Text + "\" node changed.");
                        break;
                }


If you need to update the database in one pass you can store all operation inside some dictionary using the node as a key.

Regards,
Albert
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Relative
Top achievements
Rank 1
answered on 21 Apr 2009, 07:48 AM
Hi,

[UPDATE: Looking again at the help file - it does reference the online example!] - thanks for your reply

That makes sense. I didn't see the property as I went straight the the node object. The example you are showing is different from the example I was working from in the help file.

Q1 2009:

ms-help://telerik.aspnetajax.radcontrols.2009.Q1/telerik.aspnetajax.radtreeview.2009.Q1/client-side-programming-access-client-changes-at-server.html


Might be a good idea to updat the help file as I complete missed checking the operation object

Code example from help file:

foreach (ClientOperation<RadTreeNode> operation in RadTreeView1.ClientChanges) 
 RadTreeNode node = operation.Item; 
 
 switch (operation.Type) 
 { 
  case ClientOperationType.Insert: 
   break
  case ClientOperationType.Remove: 
   break
  case ClientOperationType.Update: 
   UpdateClientOperation<RadTreeNode> update = operation as UpdateClientOperation<RadTreeNode>; 
   break
  case ClientOperationType.Clear: 
   break
 }  
 
Tags
TreeView
Asked by
Relative
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Relative
Top achievements
Rank 1
Share this question
or