如何通过复选框选择功能工具栏“提交”获取ID?

I want to make a function for toolbar "submit" and also "cancel" that can fetch id for selected checkboxes. But, here I don't know where to put it. More details, I want it the toolbar can submit id into the database if can.

Coding for toolbar

toolbar: [{ name: "submit", text: "Submit" , click: customSave},
          { name: "cancel", text: "Cancel" , click: customCancel}]

//treeview        
    var serviceRoot = "../../../HumanResource/EmployeeManagement/Designation/getTemplate.php";
    
                homogeneous = new kendo.data.HierarchicalDataSource({
                        transport: {
                            read: {
                                url: serviceRoot,
                                dataType: "json"
                            }
                        },
                        schema: {
                            model: {
                                id : "ehorsProgramID",
                                hasChildren: false,
                                children : "items"
                            }
                        },
                        
                        filter: { field: "module", operator: "startswith", value: "Accounting" }
                    });
                    
                $("#AccountingTree").kendoTreeView({
                    check: onCheck,
                    checkboxes: { checkChildren: true } ,
                    dataSource: homogeneous,
                        dataBound: function(){
                            this.expand('.k-item');
                        },
                    dataTextField: ["module","groupname","ehorsProgramName"]
                });
            
                homogeneous1 = new kendo.data.HierarchicalDataSource({
                        transport: {
                            read: {
                                url: serviceRoot,
                                dataType: "json"
                            }
                        },
                        schema: {
                            model: {
                                id : "ehorsProgramID",
                                hasChildren: false,
                                children : "items"
                            }
                        },
                        filter: { field: "module", operator: "startswith", value: "Admin & System" }
                    });
        
    
                $("#AdminSystemTree").kendoTreeView({
                    check: onCheck,
                    checkboxes: { checkChildren: true },
                    dataSource: homogeneous1,
                        dataBound: function(){
                            this.expand('.k-item');
                        },
                    dataTextField: ["module","groupname","ehorsProgramName"]
                    
                });
                
function toggleCheckAll() {
            var checkButtonValue = $("#chbAll").val();

            if(checkButtonValue == "Uncheck"){
              $("#AccountingTree .k-checkbox-wrapper input").prop("checked", true).trigger("change");
              $("#AdminSystemTree .k-checkbox-wrapper input").prop("checked", true).trigger("change");
        
        } else {
              $("#AccountingTree .k-checkbox-wrapper input").prop("checked", false).trigger("change");
              $("#AdminSystemTree .k-checkbox-wrapper input").prop("checked", false).trigger("change");
             }
      }
      
      function checkedNodeIds(nodes, checkedNodes) {
      for (var i = 0; i < nodes.length; i++) {
        if (nodes[i].checked) {
          //checkedNodes.push(nodes[i].moduleID);
         // checkedNodes.push(nodes[i].groupID);
          checkedNodes.push(nodes[i].id);
        }

        if (nodes[i].hasChildren) {
          checkedNodeIds(nodes[i].children.view(), checkedNodes);
        }
      }
    }
    function onCheck() {
      var checkedNodes  = [],treeView = $("#AccountingTree").data("kendoTreeView"),message;
      var checkedNodes2 = [],treeView2 = $("#AdminSystemTree").data("kendoTreeView"),message;
      checkedNodeIds(treeView.dataSource.view(), checkedNodes);
      checkedNodeIds(treeView2.dataSource.view(), checkedNodes);
      if (checkedNodes.length > 0) {
        message = "IDs of checked nodes: " + checkedNodes.filter(x => !!x).join(",");
      } else {
        message = "No nodes checked.";
      }

      $("#result").html(message);
      
    }
     
 

Function based on the toolbar and where do I put it in based on //treeview?

function customSave(e) {
//console.log(e);
}

function customCancel(e) {
//console.log(e);
}

Here, the output which is toolbar "submit" and "cancel" but not have a function yet: enter image description here

</div>
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐