[Script]
var checkedNodes = obj.getCheckedNodes();
var checkNodesJSONData = "";
for (i = 0; i < checkedNodes.length; i++) {
checkNodesJSONData = checkNodesJSONData + JSON.stringify(obj.getTreeData(checkedNodes[i].id));
}
$.ajax({
url: "@Url.Action("GetCheckedNodes", "Home", null)",
data: JSON.stringify({ data: checkNodesJSONData }),
type: "POST",
contentType: "application/json; charset=utf-8",
dataType: "json"
});
[Controller]
public ActionResult GetCheckedNodes(string data)
{
return View();
} |
Hi Sam,Most Welcome.Please let us know if you need any further assistance.Regards,Ashokkumar B.
Hello Ashokkumar !
I ask for your help, because I have problem with the Treeview to return the data to the controller.
1) I need to process 470 records in the TreeView, but the response time is very slow, +- 1.5'
for (i = 0; i < checkedNodes.length; i++) {
checkNodesJSONData = checkNodesJSONData + JSON.stringify(obj.getTreeData(checkedNodes[i].id));
}
// The For is very slow. I need to find a way to make it more efficient.
2) I can not find how to return successfully, the data controller to take them to the database. Always returns null value.
@section ScriptSection{
<script>
function onCreate(args) {
console.log("Treeview created successfully");
}
function getCheckedNodes() {
//create an instance from an existing TreeView.
// only after control creation you can get treeObj otherwise it throws exception.
var tree = $("#treeView").data('ejTreeView');
var obj = $("#treeView").ejTreeView('instance');
//to get TreeView data
var data = obj.getTreeData();
//to get checkednodes
var checkedNodes = obj.getCheckedNodes();
var checkNodesJSONData = "";
for (i = 0; i < checkedNodes.length; i++) {
checkNodesJSONData = checkNodesJSONData + JSON.stringify(obj.getTreeData(checkedNodes[i].id));
}
// The For is very slow. I need to find a way to make it more efficient.
$.ajax({
url: "@Url.Action("GetCheckedNodes", "User")",
type: "POST",
datatype: 'json',
contentType: "application/json; charset=utf-8",
data: JSON.stringify({ value: data })
});
console.log(checkedNodes);
}
</script>
}
Thanks for help me.
Regards,
Edgar H. Velandia
[Script]
var obj = $("#treeView").ejTreeView('instance');
var checkedNodes = obj.getCheckedNodes();
var checkNodesid = [];
for (i = 0; i < checkedNodes.length; i++) {
checkNodesid.push(checkedNodes[i].id); //get the checked nodes id
} |
[Script]
var obj = $("#treeView").ejTreeView('instance');
var checkedNodes = obj.getCheckedNodes();
var checkNodesid = [];
for (i = 0; i < checkedNodes.length; i++) {
checkNodesid.push(checkedNodes[i].id); //get the checked nodes id
}
$.ajax({
url: "@Url.Action("GetCheckedNodes", "Home", null)",
data: JSON.stringify({ data: checkNodesid }),
type: "POST",
contentType: "application/json; charset=utf-8",
dataType: "json"
});
[Controller]
public ActionResult GetCheckedNodes(string[] data){
// your code here
} |