// View part
<form id="frmUsuario" class="form-horizontal" asp-controller="MyCal" asp-action="GetValues" autocomplete="off" data-ajax="true" data-ajax-method="POST"
data-ajax-success="fnSuccess(data)" data-ajax-failure="fnFailure()">
<ejs-treeview id="treedata" name="treedata" showCheckBox="true" loadOnDemand="false">
<e-treeview-fields dataSource="Model.DataSource" id="Id" parentId="PId" text="Name" hasChildren="HasChild" expanded="expanded"></e-treeview-fields>
</ejs-treeview>
<br />
<label for="art"> Enter the node id to be checked: </label>
<input id="art" class="e-input" type="text" name="art" />
<br />
<input type="submit" id="button" value="Submit" />
</form> |
// Controller part
[HttpPost]
public IActionResult GetValues()
{
string value = HttpContext.Request.Form["art"];
ViewBag.Result = value;
return Json(value);
} |
// After ajax succeeded
function fnSuccess(data) {
console.log(data);
data = data.split(",")
var treeView = document.getElementById('treedata').ej2_instances[0];
treeView.checkAll(data);
} |