Results 1 to 9 of 9

Thread: Add node on a treepanel with direct proxy

  1. #1
    Sencha User
    Join Date
    Jul 2008
    Posts
    22
    Vote Rating
    0
      0  

    Default Add node on a treepanel with direct proxy

    Hello,

    I have a tree that is loading data with direct.
    My proxy is defined like this
    Code:
    proxy: {        type: 'direct',
            api : {
                read: data.readNodes,
                create: data.createNode
    
            },
            reader: {
                type:'json',
                root: 'data'
            }
            
        },
    I've managed to create a node for this tree with appendChild. My question is, how can I send to the server the new created node? so basically I want to send a request to createNode with details for the new node. Or maybe update the treestore?

    Thanks!

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Vote Rating
    1272
      0  

    Default

    When a non-left node is expanded, it should send a request with that node so you can load it's children.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  3. #3
    Sencha User
    Join Date
    Jul 2008
    Posts
    22
    Vote Rating
    0
      0  

    Default

    Thanks for the response, but after I've read it, I understand that I was not very clear on what I want.
    My problem was that after adding the node, in client side, in the tree, I don't know how will a send the info to the server, to add it into the database.

    I've done some digging and found that after append, the node is added to the store and then probably I should use the store.sync(). But after I call the sync method i'm having an error: "fn is undefined". The error is in the method doRequest from the class Ext.data.proxy.Direct. Don't know why "if (operation.action == 'read')" is true, I was expecting to go on create.

    Thanks!

  4. #4
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Vote Rating
    1272
      0  

    Default

    So you add a node and call store.sync(). In your store's proxy, do you have the api setup so that the create is matched to a direct function?
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  5. #5
    Sencha User
    Join Date
    Jul 2008
    Posts
    22
    Vote Rating
    0
      0  

    Default

    yeap, this is my proxy
    Code:
    proxy: {        type: 'direct',
            api : {
                read: dataProvider.model.ProtectedEntitiesEPS.getADGroups,
                create: dataProvider.model.ProtectedEntitiesEPS.addNode
            },
            reader: {
                type:'json',
                root: 'data'
            }
            
        },

  6. #6
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Vote Rating
    1272
      0  

    Default

    It's telling me that addNode isn't resolvable. What happens when you type that function into the console?
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  7. #7
    Sencha User
    Join Date
    Jul 2008
    Posts
    22
    Vote Rating
    0
      0  

    Default

    I'm getting this error: "TypeError: fn is undefined"
    this is the code for the add method:
    Code:
    var tree = Ext.getCmp("myTree");var selectedNode = tree.getSelectionModel().getLastSelected(); 
    var newNode = {};
                
                newNode.text = "testNode";
                newNode.type = 275;
    
    
                
                var appNode = selectedNode.appendChild(newNode);
    
    
    var rec = tree.getStore().getUpdatedRecords();
    tree.getStore().sync();

  8. #8
    Sencha User
    Join Date
    Jul 2008
    Posts
    22
    Vote Rating
    0
      0  

    Default

    ok, found my problem...the function for create was wrong.

    now the request is pointing to the create method, correctly, but at the server side I don't get any data from that node.

  9. #9
    Sencha User
    Join Date
    Jul 2008
    Posts
    22
    Vote Rating
    0
      0  

    Default

    solved it...my mistake, I was pointing to another function

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •