PDA

View Full Version : TreePanel: Need return value from SubmitNodes()



wexman
Apr 01, 2011, 1:51 PM
Hi,

I need to retrieve a return value (some server-side generated id) upon SubmitNodes() of a TreePanel. Is this possible somehow?

Here's my markup(simplyfied):


<ext:TreePanel runat="server" ID="TreePanel1" Lines="true" OnSubmit="TreePanel1_SubmitNodes">
<Tools>
<ext:Tool Type="Save" Qtip="Save" Handler="#{TreePanel1}.submitNodes();" />
</Tools>
</ext:TreePanel>

and code:


protected void TreePanel1_SubmitNodes(object sender, SubmitEventArgs e)
{
// do something

return; // need return value here
}


I know it's not possible to return something directly there. But is there any other way to get data back to the browser without an extra roundtrip?

Any help appreticated!

wexman
Apr 06, 2011, 6:54 AM
Hi,

just to let you know I solved this by manually preparing the tree nodes and then passing them to a custom DirectMethod, from which I can return a value:

Client code:


var SaveTrain = function () {
var nodes = TreePanel1.serializeTree();
Ext.net.DirectMethods.SaveTree(nodes, {
success: function (guid) {
TreePanel1.getRootNode().attributes["contextId"] = guid;
},
eventMask: { showMask: true }
});
}


Server code:


[DirectMethod]
public Guid SaveTree(SubmittedNode node)
{
// Do something
return Guid.NewGuid();
}