I would like to create the record from the jstree using context menu.
Please help to resolve my issue:
My Code:
contextmenu : {
"items" : function (node) {
return {
"view" : {
label: "View Record",
action: function(obj) {
window.open("/" + obj.attr("id"));
}
},
"create" : {
label: "Add New",
action: function() {
createNode(node);
}
},
**<I have removed some code >**
}
});
function createNode(parent) {
var currentParentId = parent.attr("id");
$j("#tree").jstree("create", $j("#"+currentParentId), "inside", { "data" : "NewName","state" : "leaf","attr" : { "id" : true,"rel":"noChildren"}},null, true);
}
Node is created but in Salesforce no new record created so I would like to create new record and assign the id to newly created record.
FYI I have attached the image:
Best Answer
Take a look at Visualforce remoting, it'll be quite easy to write an Apex method that supports creation of a new object with the required parameters. You'll just need to add the remoting call inside your
createNode
method.Docs: https://www.salesforce.com/us/developer/docs/pages/Content/pages_js_remoting.htm