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

treenode and client side APIs

3 Answers 123 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Andrea
Top achievements
Rank 2
Iron
Andrea asked on 19 May 2008, 05:22 PM
Hi all,
i'm trying to use some treeview client side function.

For example, I manage client side node checked event, and i set imageUrl, Category, image alt attribute and some other stuff, depending on treenode. checked value.

All works really good since I submit my changes with a button postback...

The only changes i get server side is the checked value, but all other properties and attributes are lost.

Here is an example of what functions i'm using from APIs.
Any idea about how can I get changed values server side?
   function SwitchEditMode(menuItem, treeNode)  
               {    
                  if(treeNode.get_checked() == true)  
                  {  
                    switch(menuItem.get_value())  
                    {  
                        case "0":  
                            treeNode._imageElement.alt = ReadOnlyMsg;  
                            treeNode.get_element().all[4].title=ReadOnlyMsg;  
                            treeNode.set_selectedImageUrl(imageReadOnlyUrl);  
                            treeNode.set_imageUrl(imageReadOnlyUrl);  
                            treeNode.set_category("0");  
                            break;  
                        case "1":  
                            treeNode._imageElement.alt = EditableMsg;  
                            treeNode.get_element().all[4].title=EditableMsg;  
                            treeNode.set_selectedImageUrl(imageEditableUrl);  
                            treeNode.set_imageUrl(imageEditableUrl);  
                            treeNode.set_category("1");  
                            break;  
                    }  
                  }    
                } 

Thank you

3 Answers, 1 is accepted

Sort by
0
Accepted
Veselin Vasilev
Telerik team
answered on 21 May 2008, 07:26 AM
Hi Andrea,

Only properties are persisted server-side. Any HTML Dom attributes such as "alt" will not be persisted.
One of the options is to save these attributes as custom attributes of the nodes and load them in pageLoad().

To save the properties like selectedImageUrl and category you need to wrap them with tree.trackChanges() and tree.commitChanges() methods:

  function SwitchEditMode(menuItem, treeNode)   
               {     
                  if(treeNode.get_checked() == true)   
                  {   
                    var tree = treeNode.get_treeView(); 
                    tree.trackChanges(); 
                    switch(menuItem.get_value())   
                    {   
                        case "0":   
                            treeNode._imageElement.alt = ReadOnlyMsg;   
                            treeNode.get_element().all[4].title=ReadOnlyMsg;   
                            treeNode.set_selectedImageUrl(imageReadOnlyUrl);   
                            treeNode.set_imageUrl(imageReadOnlyUrl);   
                            treeNode.set_category("0");   
                            break;   
                        case "1":   
                            treeNode._imageElement.alt = EditableMsg;   
                            treeNode.get_element().all[4].title=EditableMsg;   
                            treeNode.set_selectedImageUrl(imageEditableUrl);   
                            treeNode.set_imageUrl(imageEditableUrl);   
                            treeNode.set_category("1");   
                            break;   
                    }   
                    tree.commitChanges(); 
                  }     
                }  

I hope this helps.

Sincerely yours,
Veskoni
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Accepted
Veselin Vasilev
Telerik team
answered on 21 May 2008, 07:56 AM
Hello Andrea,

I have one more suggestion: do not use private members like treeNode._imageElement
It is always a good practice to use the public method: treeNode.get_imageElement()


Regards,
Veskoni
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Andrea
Top achievements
Rank 2
Iron
answered on 21 May 2008, 10:57 AM
ok it's working fine, really thank you for your suggestion.
Tags
TreeView
Asked by
Andrea
Top achievements
Rank 2
Iron
Answers by
Veselin Vasilev
Telerik team
Andrea
Top achievements
Rank 2
Iron
Share this question
or