-
2 Feb 2012 5:04 AM #1
Add node on a treepanel with direct proxy
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
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?Code:proxy: { type: 'direct', api : { read: data.readNodes, create: data.createNode }, reader: { type:'json', root: 'data' } },
Thanks!
-
2 Feb 2012 7:12 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,118
- Vote Rating
- 453
When a non-left node is expanded, it should send a request with that node so you can load it's children.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
2 Feb 2012 7:21 AM #3
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!
-
2 Feb 2012 7:37 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,118
- Vote Rating
- 453
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 @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
2 Feb 2012 8:26 AM #5
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' } },
-
2 Feb 2012 8:42 AM #6Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,118
- Vote Rating
- 453
It's telling me that addNode isn't resolvable. What happens when you type that function into the console?
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
2 Feb 2012 9:26 AM #7
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();
-
3 Feb 2012 1:21 AM #8
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.
-
3 Feb 2012 4:12 AM #9
solved it...my mistake, I was pointing to another function


Reply With Quote