|
public menuclick(args: MenuEventArgs) {
let targetNodeId: string = this.treevalidate.selectedNodes[0];
if (args.item.text == "Add New Item") {
this.ejDialog.show();
} else if (args.item.text == "Remove Item") {
// Remove the item using Remove node method.
this.treevalidate.removeNodes([targetNodeId]);
} else if (args.item.text == "Rename Item") {
// Edit the node using begin edit method.
this.treevalidate.beginEdit(targetNodeId);
}
}
public hideDialog: EmitType<object> = () => {
var nodeId = document.getElementById("node_id").value;
var nodeText = document.getElementById("node_text").value;
// Hide the Dialog object.
this.ejDialog.hide();
let targetNodeId: string = this.treevalidate.selectedNodes[0];
var newNode = [{ orderID: parseInt(nodeId), customerID: nodeText.toString() }]
// Add the node using AddNode method.
this.treevalidate.addNodes(newNode, targetNodeId, null);
this.index++;
}; |
|
public data: Object = new DataManager({
url: 'https://localhost:44356/Home/Post',
insertUrl:'https://localhost:44356/Home/Insert',
removeUrl:'https://localhost:44356/Home/Delete',
updateUrl:'https://localhost:44356/Home/Update',
adaptor: new UrlAdaptor,
crossDomain: true,
//offline: true
});
Server side Method.
[HttpPost]
public ActionResult Insert([FromBody]CRUDModel<TreeDetails> value)
{
TreeDetails.GetAllRecords().Insert(0, value.value);
return Json(value.value);
}
[HttpPost]
public ActionResult Delete([FromBody]CRUDModel<TreeDetails> value)
{
TreeDetails.GetAllRecords().Remove(TreeDetails.GetAllRecords().Where(or => or.orderID == int.Parse(value.key.ToString())).FirstOrDefault());
var data = TreeDetails.GetAllRecords();
return Json(data);
} |