gpt4 book ai didi

c# - Telerik Net Core Treeview 模板-从所选项目的输入框中获取值

转载 作者:行者123 更新时间:2023-12-03 22:51:25 33 4
gpt4 key购买 nike

如何从选定的 inputbox (和 checkboxitem )的 subitems 中获取值?
我可以获得checkedItem(item.Name)的标签,但我现在不知道如何获取inputbox的值。

<script id="treeview_distribute_template" type="text/kendo-ui-template">
<table>
<tbody>
<tr>
<td width="500px;">
#= item.Name # &nbsp;
</td>
<td >
<input id='comment_input' type='text' style="width:500px;" />
</td>
</tr>
</tbody>
</table>
</script>

function getCheckedNodes(nodes) {
var node, childCheckedNodes;
var checkedNodes = [];
for (var i = 0; i < nodes.length; i++) {
node = nodes[i];
if (node.checked) {
checkedNodes.push(node);
}
if (node.hasChildren) {
childCheckedNodes = getCheckedNodes(node.children.view());
if (childCheckedNodes.length > 0) {
checkedNodes = checkedNodes.concat(childCheckedNodes);
}
}
}
return checkedNodes;
}
enter image description here

最佳答案

SOLVED:    
var inputValues = [];
function onCheck(e) {
var checkedNodes = [];
var treeView = $("#treeview").data("kendoTreeView");
var node = e.node;
var val = $(node).find('input.comment_input').val();
var dataItem = e.sender.dataItem(e.node);
getCheckedNodesText(dataItem, val)

if (checkedNodes.length > 0) {
message = "IDs of checked nodes: " + checkedNodes.join(",");
} else {
message = "No nodes checked.";
}

$("#selected-count").html(message);
}

function removeFromArray(array, value) {
for (var i = 0; i < array.length; i++) {
if (array[i].departmentId == value)
array.splice(i, 1);
}
return array;
}

function getCheckedNodesText(nodes, checkedNodeText) {
if (nodes.checked) {
inputValues.push({ departmentId: nodes.id, value: checkedNodeText });
}
else {
inputValues = removeFromArray(inputValues, nodes.id);
}

}

function actionOK(e) {
treeView = $("#treeview").data("kendoTreeView");
var checkedNodes = getCheckedItems(treeView);
var node = e.node;
updateResult(checkedNodes);
$.ajax
(
{
url: '@Url.Action("Distribute", "Document")',
data: { 'selectedItems': JSON.stringify(checkedNodes), 'idDoc': document.getElementById("SelectedDocId").value, 'notes': JSON.stringify(inputValues) },
type: 'POST',
success: function (responce)
{

},
}
);
}

关于c# - Telerik Net Core Treeview 模板-从所选项目的输入框中获取值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62633271/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com